From 15f947e329ffae784073514b998260da858cb160 Mon Sep 17 00:00:00 2001
From: white <1293616053@qq.com>
Date: Mon, 23 Sep 2024 14:53:24 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?=
=?UTF-8?q?=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
hybrid/html/ai.html | 95 +++++++--
pages/index/index.vue | 117 +++++++----
pages/login/login.vue | 44 +----
.../components/uqrcode/uqrcode.vue | 15 +-
uni_modules/liu-data-select/changelog.md | 6 +
.../liu-data-select/liu-data-select.vue | 186 ++++++++++++++++++
uni_modules/liu-data-select/license.md | 6 +
uni_modules/liu-data-select/package.json | 85 ++++++++
uni_modules/liu-data-select/readme.md | 111 +++++++++++
.../dist/dev/app-plus/hybrid/html/ai.html | 81 ++++++--
10 files changed, 641 insertions(+), 105 deletions(-)
create mode 100644 uni_modules/liu-data-select/changelog.md
create mode 100644 uni_modules/liu-data-select/components/liu-data-select/liu-data-select.vue
create mode 100644 uni_modules/liu-data-select/license.md
create mode 100644 uni_modules/liu-data-select/package.json
create mode 100644 uni_modules/liu-data-select/readme.md
diff --git a/hybrid/html/ai.html b/hybrid/html/ai.html
index 1bc5480..c972693 100755
--- a/hybrid/html/ai.html
+++ b/hybrid/html/ai.html
@@ -272,14 +272,13 @@
/*
* 拿到匹配的文字下标
*/
- let QSindex = containsKeywordRegex(params.msg);
- console.log(QSindex)
+ var QSindex = containsKeywordRegex(params.msg);
if (QSindex == 0) {
const obj = exampleData.filter(item => item.type == "bloodGlucose");
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近测量的血糖为${obj[0].data_msg}毫摩尔/升`
} else {
- alert ('当前数据为空');
+ speed(`血糖数据为空, 请连接或同步设备数据`)
return
}
}
@@ -288,7 +287,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近睡眠时长为${obj[0].data_msg[0].sleepTotalTime}分钟`
} else {
- alert ('当前数据为空');
+ speed(`睡眠数据为空, 请连接或同步设备数据`)
return
}
}
@@ -297,7 +296,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近测量的血氧为${obj[0].data_msg}毫摩尔/升`
} else {
- alert ('当前数据为空');
+ speed(`血氧数据为空, 请连接或同步设备数据`)
return
}
}
@@ -306,7 +305,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近测量的血压为${obj[0].data_msg.bloodPressureLow}/${obj[0].data_msg.bloodPressureHigh}毫摩尔/升`
} else {
- alert ('当前数据为空');
+ speed(`血压数据为空, 请连接或同步设备数据`)
return
}
}
@@ -320,7 +319,7 @@
高密度脂蛋白为${obj[0].data_msg.cholesterol/100},
低密度脂蛋白为${obj[0].data_msg.cholesterol/100}, `
} else {
- alert ('当前数据为空');
+ speed(`血脂数据为空, 请连接或同步设备数据`)
return
}
}
@@ -329,7 +328,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近测量的心率为${obj[0].data_msg[0]}, `
} else {
- alert ('当前数据为空');
+ speed(`心率数据为空, 请连接或同步设备数据`)
return
}
}
@@ -338,7 +337,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近测量的体温为${obj[0].data_msg}摄氏度`
} else {
- alert ('当前数据为空');
+ speed(`体温数据为空, 请连接或同步设备数据`)
return
}
}
@@ -347,7 +346,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近心电图测量结果为${obj[0].data_msg.heartRate}次/分`
} else {
- alert ('当前数据为空');
+ speed(`心电图数据为空, 请连接或同步设备数据`)
return
}
}
@@ -356,11 +355,10 @@
if (obj[0].data_msg.BMI) {
Question = `请模仿全科医生的口吻与我对话,我最近身体成分结果为${obj[0].data_msg.BMI}`
} else {
- alert ('当前数据为空');
+ speed(`身体成分数据为空, 请连接或同步设备数据`)
return
}
}
-
if (QSindex == 10) {
const obj = exampleData.filter(item => item.type == "stepIndex");
if (obj[0].data_msg) {
@@ -368,7 +366,7 @@
${obj[0].data_msg.calorie/10}千卡,
${obj[0].data_msg.distance/1000}公里`
} else {
- alert ('当前数据为空');
+ speed(`运动数据为空, 请连接或同步设备数据`)
return
}
}
@@ -598,6 +596,77 @@
modal.style.display = 'none';
dialog.style.display = 'none';
}
+
+ function speed(str) {
+ fetch("https://eastasia.tts.speech.microsoft.com/cognitiveservices/v1", {
+ method: 'POST',
+ headers: {
+ 'Authorization': 'Bearer ' + token,
+ 'Ocp-Apim-Subscription-Key': '58e9b39b8f6f48fe8d01f85b727ff737',
+ 'Content-Type': 'application/ssml+xml',
+ 'X-Microsoft-OutputFormat': 'audio-24khz-48kbitrate-mono-mp3'
+ },
+ responseType: 'arraybuffer',
+ body: `
+
+
+
+ ${str}
+
+
+
+ `,
+ }).then(async(response) => {
+ const content_bytes = await response.arrayBuffer();
+ const blob = new Blob([content_bytes], { type: 'audio/mp3' });
+ const blobUrl = URL.createObjectURL(blob);
+
+ // 设置音频源
+ audioElement.src = blobUrl;
+
+ // 播放音频
+ audioElement.play();
+
+ // 循环视频
+ replayVideoSegment(60, 120);
+
+ // 计算所需时间
+ const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
+
+ // 开始倒计时
+ var totalTime = speakingTime;
+ var countdown = setInterval(function() {
+ // 更新剩余时间
+ totalTime --;
+ if (totalTime <= 0) {
+ // 停止倒计时
+ clearInterval(countdown);
+ replayVideoSegment(0, 60);
+ }
+ }, 1000);
+
+ hideModal()
+ }).catch(e => {
+ hideModal();
+ });
+
+ startRec.style.display = 'block';
+ runRec.style.display = 'none';
+ }
+
+ function throttle(fn, wait) {
+ let lastTime = 0; // 上一次调用的时间
+
+ return function (...args) {
+ const now = Date.now(); // 当前时间
+
+ // 如果距离上次调用已经超过设定时间,则调用函数
+ if (now - lastTime > wait) {
+ lastTime = now; // 更新上一次调用的时间
+ fn.apply(this, args); // 以正确的`this`和参数调用函数
+ }
+ };
+ }
};
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 6598c2d..a20e722 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -1,6 +1,5 @@
-
@@ -18,8 +17,19 @@
+
+
+
+ {{name2 || '选择设备'}}
+
+
+
+ 退出登录
+
+
-
+
卡路里
@@ -41,7 +51,6 @@
公里
-
{{(dataListsNew.stepIndex.device_real_time)}}
@@ -49,7 +58,7 @@
-
+
{{getNameByKey('sleep')}}
@@ -109,8 +118,6 @@
%
-
-
@@ -224,28 +231,6 @@
-
-
尿酸
@@ -268,7 +253,7 @@
-
+
{{getNameByKey('bloodLiquid')}}
@@ -316,6 +301,8 @@
+
+
@@ -362,7 +349,13 @@
}
},
- urlLink: ''
+ name: '',
+ name1: '',
+ name2: '',
+ deviceList: [],
+
+
+ urlLink: '',
}
},
onLoad() {
@@ -434,6 +427,10 @@
this.$refs.paging.complete();
}
);
+
+ this.$store.dispatch('api/getBindUserDeviceId').then(res => {
+ this.deviceList = res;
+ });
},
mkHourMin(min){
if(min < 60){
@@ -453,7 +450,23 @@
if (dateTimeStr) {
return dateTimeStr.replace(/-/g, ' ').replace(' ', ' ', 2).replace(' ', ':');
}
- }
+ },
+ // 退出登录
+ outlogin() {
+ this.$store.commit('api/setApiToken', '')
+ this.$store.commit('api/setActiceDevice', '')
+ this.$store.commit('api/setUserInfo', '')
+
+ uni.reLaunch({
+ url: "/pages/login/login"
+ })
+ },
+
+ // 选中的设备
+ changeDev(item) {
+ this.$store.commit('api/setActiceDevice', item)
+ this.onRefresh();
+ }
}
}
@@ -549,6 +562,17 @@
justify-content: space-between;
padding: 0rpx 40rpx;
}
+ .control {
+ margin: 0rpx 40rpx;
+ .btn {
+ font-size: 36rpx;
+ font-weight: 800;
+ margin-bottom: 30rpx;
+ padding: 30rpx 50rpx;
+ border-radius: 20rpx ;
+ -webkit-box-shadow: 0 0 60rpx 0 rgba(43,86,112,.1) ;
+ }
+ }
.content-item {
width: 42%;
margin: 20rpx 10rpx;
@@ -558,7 +582,6 @@
-webkit-box-shadow: 0 0 60rpx 0 rgba(43,86,112,.1) ;
box-shadow: 0 0 60rpx 0 rgba(43,86,112,.1) ;
position: relative;
- height: 200rpx;
overflow: hidden;
.title {
font-size: 38rpx;
@@ -567,7 +590,7 @@
}
.row-time {
position: absolute;
- bottom: 30rpx;
+ bottom: 10rpx;
right: 30rpx;
font-size: 28rpx;
color: grey;
@@ -675,5 +698,33 @@
background-color: #06193a;
margin: 0rpx 20rpx;
justify-content: center;
+ }
+
+
+
+ .page-main {
+ padding: 20rpx;
+ }
+
+ .title {
+ margin: 32rpx;
+ }
+
+ .btn-info {
+ width: 600rpx;
+ height: 88rpx;
+ margin: 0 auto;
+ margin-top: 30rpx;
+ border: solid #f0f0f0 1px;
+ border-radius: 12rpx;
+ padding: 0 30rpx;
+ }
+
+ .btn-info1 {
+ width: 300rpx;
+ border-radius: 12rpx;
+ }
+ .card {
+ width: 800rpx !important;
}
diff --git a/pages/login/login.vue b/pages/login/login.vue
index bd4e37b..d3962b8 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -21,13 +21,13 @@
@click="getLoginCode"
>
-
@@ -65,10 +65,6 @@
找回密码
|
注册账号
- |
-
- 扫码登录
-
@@ -99,9 +95,6 @@
isRotate: false, //是否加载旋转
isFocus: true // 是否聚焦
};
- },
- watch(){
-
},
onLoad() {
let token = this.$store.getters['api/getApiToken']
@@ -125,27 +118,16 @@
_this= this;
},
methods: {
-
back() {
uni.navigateTo({
url: '/pages/index/index'
})
},
- doLoginType(type){
- this.login_type = type
- if(type == 0){
- this.qrCodeMsg = '加载中...'
- this.qrCode = ''
- this.getLoginCode()
- }else{
- this.qrCodeMsg = '加载中...'
- this.qrCode = ''
- }
- },
getLoginCode(){
// 验证一下token是否有值
let token = this.$store.getters['api/getApiToken']
if(!token){
+ console.log('无token')
this.$store.dispatch('api/getLoginCode').then(res => {
this.qrCode = 'https://ai.agrimedia.cn/qrcodeLogin/index?qrcode=' + res.key
this.qrCodeVal = res.key
@@ -174,24 +156,9 @@
}
})
},1000)
- // this.$store.dispatch('api/checkLoginCode',{
- // key:this.qrCodeVal
- // }).then(res => {
- // if(res.status == 0){
- // setTimeout(this.checkQrCode(),2000)
- // }
- // if(res.status == 1){
- // this.$store.commit('api/setApiToken',res.token)
- // console.log('123')
- // uni.reLaunch({
- // url: '/pages/index/index'
- // })
- // }
- // //
- // })
}
},
- startLogin(e){
+ startLogin(e){
//登录
if(this.isRotate){
//判断是否加载中,避免重复点击请求
@@ -218,10 +185,9 @@
uni.showLoading({
title: '登录中'
});
- this.$store.dispatch('api/dologin', { mobile: this.phoneData, password: this. passData }).then(res => {
+ this.$store.dispatch('api/dologin', { mobile: this.phoneData, password: this.passData }).then(res => {
if (res.token) {
this.$store.commit('api/setApiToken',res.token)
- console.log('123')
uni.reLaunch({
url: '/pages/index/index'
})
diff --git a/uni_modules/Sansnn-uQRCode/components/uqrcode/uqrcode.vue b/uni_modules/Sansnn-uQRCode/components/uqrcode/uqrcode.vue
index 8ae9598..2975922 100644
--- a/uni_modules/Sansnn-uQRCode/components/uqrcode/uqrcode.vue
+++ b/uni_modules/Sansnn-uQRCode/components/uqrcode/uqrcode.vue
@@ -294,22 +294,23 @@
},
value: {
handler() {
- if (this.auto) {
+ if (this.auto) {
this.remake();
}
}
},
size: {
handler() {
- if (this.auto) {
+ if (this.auto) {
this.remake();
}
}
},
options: {
handler() {
- if (this.auto) {
- this.remake();
+ if (this.auto) {
+ console.log('3')
+ // this.remake();
}
},
deep: true
@@ -339,7 +340,7 @@
this.templateOptions.canvasTransform = `scale(${this.templateOptions.size / this.templateOptions.canvasWidth}, ${this.templateOptions.size /
this.templateOptions.canvasHeight})`;
}
- if (this.start) {
+ if (this.start) {
this.make();
}
},
@@ -379,7 +380,7 @@
/**
* 绘制二维码
*/
- async draw(callback = {}, isDrawDelegate = false) {
+ async draw(callback = {}, isDrawDelegate = false) {
if (typeof callback.success != 'function') {
callback.success = () => {};
}
@@ -650,7 +651,7 @@
/**
* 生成二维码
*/
- make(callback = {}) {
+ make(callback = {}) {
this.makeExecuted = true;
this.makeing = true;
this.isError = false;
diff --git a/uni_modules/liu-data-select/changelog.md b/uni_modules/liu-data-select/changelog.md
new file mode 100644
index 0000000..f285593
--- /dev/null
+++ b/uni_modules/liu-data-select/changelog.md
@@ -0,0 +1,6 @@
+## 1.0.2(2023-06-09)
+增加预览二维码
+## 1.0.1(2023-05-10)
+增加示例
+## 1.0.0(2023-05-10)
+初始发布
diff --git a/uni_modules/liu-data-select/components/liu-data-select/liu-data-select.vue b/uni_modules/liu-data-select/components/liu-data-select/liu-data-select.vue
new file mode 100644
index 0000000..9aa3ec1
--- /dev/null
+++ b/uni_modules/liu-data-select/components/liu-data-select/liu-data-select.vue
@@ -0,0 +1,186 @@
+
+
+
+
+
+
+
+
+
+
+ {{item.device_id}}
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/uni_modules/liu-data-select/license.md b/uni_modules/liu-data-select/license.md
new file mode 100644
index 0000000..029bf39
--- /dev/null
+++ b/uni_modules/liu-data-select/license.md
@@ -0,0 +1,6 @@
+### 1、本插件可免费下载使用;
+### 2、未经许可,严禁复制本插件派生同类插件上传插件市场;
+### 3、未经许可,严禁在插件市场恶意复制抄袭本插件进行违规获利;
+### 4、对本软件的任何使用都必须遵守这些条款,违反这些条款的个人或组织将面临法律追究。
+
+
diff --git a/uni_modules/liu-data-select/package.json b/uni_modules/liu-data-select/package.json
new file mode 100644
index 0000000..5087957
--- /dev/null
+++ b/uni_modules/liu-data-select/package.json
@@ -0,0 +1,85 @@
+{
+ "id": "liu-data-select",
+ "displayName": "select下拉框选择器",
+ "version": "1.0.2",
+ "description": "非常简单好用的select下拉框选择器,可自定义选择框大小、颜色、内容等",
+ "keywords": [
+ "下拉",
+ "下拉框",
+ "下拉选择",
+ "select",
+ "选择器"
+ ],
+ "repository": "",
+ "engines": {
+ "HBuilderX": "^3.1.0"
+ },
+ "dcloudext": {
+ "type": "component-vue",
+ "sale": {
+ "regular": {
+ "price": "0.00"
+ },
+ "sourcecode": {
+ "price": "0.00"
+ }
+ },
+ "contact": {
+ "qq": ""
+ },
+ "declaration": {
+ "ads": "无",
+ "data": "无",
+ "permissions": "无"
+ },
+ "npmurl": ""
+ },
+ "uni_modules": {
+ "dependencies": [],
+ "encrypt": [],
+ "platforms": {
+ "cloud": {
+ "tcb": "y",
+ "aliyun": "y"
+ },
+ "client": {
+ "Vue": {
+ "vue2": "y",
+ "vue3": "u"
+ },
+ "App": {
+ "app-vue": "u",
+ "app-nvue": "u"
+ },
+ "H5-mobile": {
+ "Safari": "y",
+ "Android Browser": "y",
+ "微信浏览器(Android)": "y",
+ "QQ浏览器(Android)": "y"
+ },
+ "H5-pc": {
+ "Chrome": "u",
+ "IE": "u",
+ "Edge": "u",
+ "Firefox": "u",
+ "Safari": "u"
+ },
+ "小程序": {
+ "微信": "y",
+ "阿里": "u",
+ "百度": "u",
+ "字节跳动": "u",
+ "QQ": "u",
+ "钉钉": "u",
+ "快手": "u",
+ "飞书": "u",
+ "京东": "u"
+ },
+ "快应用": {
+ "华为": "u",
+ "联盟": "u"
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/uni_modules/liu-data-select/readme.md b/uni_modules/liu-data-select/readme.md
new file mode 100644
index 0000000..57eea90
--- /dev/null
+++ b/uni_modules/liu-data-select/readme.md
@@ -0,0 +1,111 @@
+### liu-data-select适用于uni-app项目的select下拉框选择器组件
+### 本组件目前兼容微信小程序、H5
+### 本组件是非常简单好用的select下拉框选择器,可点击任意元素弹出,可自定义选择框大小、颜色、内容等,源码简单易修改
+# --- 扫码预览、关注我们 ---
+
+## 扫码关注公众号,查看更多插件信息,预览插件效果!
+
+
+
+### 使用方式
+``` 示例
+
+
+ 示例一:
+
+
+
+
+ 示例二:
+
+
+
+
+ 示例三:
+
+ {{name2 || '点击选择'}}
+
+
+
+
+
+
+
+```
+
+### 属性说明
+| 名称 | 类型 | 默认值 | 描述 |
+| ----------------------------|---------------- | ---------------------- | ---------------|
+| elementId | String | | 所点击元素id(必须传)
+| dataList | Array | [] | 下拉框数据源
+| bgColor | String | #FFFFFF | 下拉框背景色
+| radius | Number | 8 | 下拉框圆角(rpx)
+| dWidth | Number | 0 | 下拉框宽度(rpx),不传则默认取所点击元素的宽度
+| dHeight | Number | 0 | 下拉框高度(rpx),不传则默认由内容撑开
+| dMaxHeight | Number | 0 | 下拉框最大高度(rpx),超出则内部滚动
+| color | String | #333333 | 字体颜色
+| fontSize | Number | 28 | 字体大小(rpx)
+| lineHeight | Number | 66 | 字体行高(rpx)
+| @change | Function | | 点击选项回调事件
+
+
+
+
+
+
+
diff --git a/unpackage/dist/dev/app-plus/hybrid/html/ai.html b/unpackage/dist/dev/app-plus/hybrid/html/ai.html
index 1bc5480..94ff0a7 100644
--- a/unpackage/dist/dev/app-plus/hybrid/html/ai.html
+++ b/unpackage/dist/dev/app-plus/hybrid/html/ai.html
@@ -272,14 +272,13 @@
/*
* 拿到匹配的文字下标
*/
- let QSindex = containsKeywordRegex(params.msg);
- console.log(QSindex)
+ var QSindex = containsKeywordRegex(params.msg);
if (QSindex == 0) {
const obj = exampleData.filter(item => item.type == "bloodGlucose");
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近测量的血糖为${obj[0].data_msg}毫摩尔/升`
} else {
- alert ('当前数据为空');
+ speed(`血糖数据为空, 请连接或同步设备数据`)
return
}
}
@@ -288,7 +287,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近睡眠时长为${obj[0].data_msg[0].sleepTotalTime}分钟`
} else {
- alert ('当前数据为空');
+ speed(`睡眠数据为空, 请连接或同步设备数据`)
return
}
}
@@ -297,7 +296,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近测量的血氧为${obj[0].data_msg}毫摩尔/升`
} else {
- alert ('当前数据为空');
+ speed(`血氧数据为空, 请连接或同步设备数据`)
return
}
}
@@ -306,7 +305,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近测量的血压为${obj[0].data_msg.bloodPressureLow}/${obj[0].data_msg.bloodPressureHigh}毫摩尔/升`
} else {
- alert ('当前数据为空');
+ speed(`血压数据为空, 请连接或同步设备数据`)
return
}
}
@@ -320,7 +319,7 @@
高密度脂蛋白为${obj[0].data_msg.cholesterol/100},
低密度脂蛋白为${obj[0].data_msg.cholesterol/100}, `
} else {
- alert ('当前数据为空');
+ speed(`血脂数据为空, 请连接或同步设备数据`)
return
}
}
@@ -329,7 +328,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近测量的心率为${obj[0].data_msg[0]}, `
} else {
- alert ('当前数据为空');
+ speed(`心率数据为空, 请连接或同步设备数据`)
return
}
}
@@ -338,7 +337,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近测量的体温为${obj[0].data_msg}摄氏度`
} else {
- alert ('当前数据为空');
+ speed(`体温数据为空, 请连接或同步设备数据`)
return
}
}
@@ -347,7 +346,7 @@
if (obj[0].data_msg) {
Question = `请模仿全科医生的口吻与我对话,我最近心电图测量结果为${obj[0].data_msg.heartRate}次/分`
} else {
- alert ('当前数据为空');
+ speed(`心电图数据为空, 请连接或同步设备数据`)
return
}
}
@@ -356,11 +355,10 @@
if (obj[0].data_msg.BMI) {
Question = `请模仿全科医生的口吻与我对话,我最近身体成分结果为${obj[0].data_msg.BMI}`
} else {
- alert ('当前数据为空');
+ speed(`身体成分数据为空, 请连接或同步设备数据`)
return
}
}
-
if (QSindex == 10) {
const obj = exampleData.filter(item => item.type == "stepIndex");
if (obj[0].data_msg) {
@@ -368,7 +366,7 @@
${obj[0].data_msg.calorie/10}千卡,
${obj[0].data_msg.distance/1000}公里`
} else {
- alert ('当前数据为空');
+ speed(`运动数据为空, 请连接或同步设备数据`)
return
}
}
@@ -598,6 +596,63 @@
modal.style.display = 'none';
dialog.style.display = 'none';
}
+
+ function speed(str) {
+ fetch("https://eastasia.tts.speech.microsoft.com/cognitiveservices/v1", {
+ method: 'POST',
+ headers: {
+ 'Authorization': 'Bearer ' + token,
+ 'Ocp-Apim-Subscription-Key': '58e9b39b8f6f48fe8d01f85b727ff737',
+ 'Content-Type': 'application/ssml+xml',
+ 'X-Microsoft-OutputFormat': 'audio-24khz-48kbitrate-mono-mp3'
+ },
+ responseType: 'arraybuffer',
+ body: `
+
+
+
+ ${str}
+
+
+
+ `,
+ }).then(async(response) => {
+ const content_bytes = await response.arrayBuffer();
+ const blob = new Blob([content_bytes], { type: 'audio/mp3' });
+ const blobUrl = URL.createObjectURL(blob);
+
+ // 设置音频源
+ audioElement.src = blobUrl;
+
+ // 播放音频
+ audioElement.play();
+
+ // 循环视频
+ replayVideoSegment(60, 120);
+
+ // 计算所需时间
+ const speakingTime = calculateSpeakingTime(content.data.choices[0].text);
+
+ // 开始倒计时
+ var totalTime = speakingTime;
+ var countdown = setInterval(function() {
+ // 更新剩余时间
+ totalTime --;
+ if (totalTime <= 0) {
+ // 停止倒计时
+ clearInterval(countdown);
+ replayVideoSegment(0, 60);
+ }
+ }, 1000);
+
+ hideModal()
+ }).catch(e => {
+ hideModal();
+ });
+
+ startRec.style.display = 'block';
+ runRec.style.display = 'none';
+ }
};