浏览代码

语音大模型

maxiaoxiao 9 月之前
父节点
当前提交
15c230c8d6
共有 4 个文件被更改,包括 52 次插入36 次删除
  1. 5 0
      package-lock.json
  2. 20 0
      src/api/aiModel.js
  3. 26 35
      src/views/aiModel/index.vue
  4. 1 1
      static/Config/config.js

+ 5 - 0
package-lock.json

@@ -13806,6 +13806,11 @@
         "resolve": "^1.1.6"
       }
     },
+    "recorder-core": {
+      "version": "1.3.24040900",
+      "resolved": "https://registry.npmmirror.com/recorder-core/-/recorder-core-1.3.24040900.tgz",
+      "integrity": "sha512-QVOXHqrQhQ5FMgXTKh4P7oc31Qex2Q5skgBT972+0wrtwHr76zMnrybo48/VyUhS75whRxMFJ5yQpv+wj333Bw=="
+    },
     "redent": {
       "version": "1.0.0",
       "resolved": "https://registry.npm.taobao.org/redent/download/redent-1.0.0.tgz",

+ 20 - 0
src/api/aiModel.js

@@ -0,0 +1,20 @@
+export function GetMsg(msg) {
+    return axios({
+        method: "POST",
+        url: `${window.aiURI}/msg`,
+        data: JSON.stringify({ msg }),
+        headers: {
+            "Content-Type": "application/json",
+        },
+    })
+}
+export function uploadAudio(data) {
+    return axios({
+        method: "POST",
+        url: `${window.aiURI}/upload`,
+        data,
+        headers: {
+            "Content-Type": "application/json",
+        },
+    })
+}

+ 26 - 35
src/views/aiModel/index.vue

@@ -30,13 +30,9 @@
               autoplay
               :src="item.mp3url"
             ></audio>
-            <div>
+            <div v-if="item.content">
               <span>{{ item.content }}</span>
-              <i
-                v-if="item.content"
-                class="el-icon-document-copy"
-                @click="copy(item)"
-              ></i>
+              <i class="el-icon-document-copy" @click="copy(item)"></i>
             </div>
           </div>
           <div class="header-img">
@@ -96,14 +92,7 @@ export default {
   props: {},
   data() {
     return {
-      questionList: [
-        { type: 0, mp3url: "" },
-        {
-          type: "selectLand",
-          content: "sss",
-          data: { rwbsm: "5f3d25e556374e78966feca5a64fa887" },
-        },
-      ],
+      questionList: [],
       defaultMsg:
         "我要在抱坡区进行选址,用地面积30到50亩,选择居住用地,距离幼儿园200米,距离医院300米,距离火葬场大于5000米",
       sendContent: "",
@@ -162,24 +151,7 @@ export default {
     stop() {
       let _this = this;
       record.stopRecorder(function (res) {
-        console.log("-blob----", res);
-        _this.questionList.push({
-          type: 0,
-          mp3url: (window.URL || webkitURL).createObjectURL(res.blob),
-          mstatus: 0,
-        });
-        let mindex = _this.questionList.length - 1;
-        /**处理 */
-        uploadAudio(res.formData)
-          .then((ares) => {
-            if (ares.status == 200) {
-              _this.questionList[mindex].content = ares.data.voiceMsg;
-              _this.sendToBackend(ares.data.voiceMsg, mindex);
-            } else {
-              _this.$message.error(ares.data.msg);
-            }
-          })
-          .catch(() => {});
+        _this.upload(res);
       });
       this.spdisabled = false;
     },
@@ -212,6 +184,25 @@ export default {
         this.stop();
       }
     },
+    upload({ blob, formData }) {
+      this.questionList.push({
+        type: 0,
+        mp3url: (window.URL || webkitURL).createObjectURL(blob),
+        mstatus: 0,
+      });
+      let mindex = this.questionList.length - 1;
+      /**处理 */
+      uploadAudio(formData)
+        .then((ares) => {
+          if (ares.status == 200) {
+            this.questionList[mindex].content = ares.data.voiceMsg;
+            this.sendToBackend(ares.data.voiceMsg, mindex);
+          } else {
+            this.$message.error(ares.data.msg);
+          }
+        })
+        .catch(() => {});
+    },
     sendToBackend(msg, mindex) {
       this.questionList[mindex].mstatus = 0;
       GetMsg(msg)
@@ -365,6 +356,9 @@ export default {
       i {
         font-size: 20px;
       }
+      .el-icon-warning {
+        color: #ff6666;
+      }
     }
   }
   audio {
@@ -415,9 +409,6 @@ export default {
     font-size: 40px;
     cursor: pointer;
   }
-  .el-icon-warning {
-    color: red;
-  }
   .no {
     color: #2f2f39;
   }

+ 1 - 1
static/Config/config.js

@@ -1,7 +1,7 @@
 //后台地址配置
 window.axiosURI = "http://192.168.60.2:8080";
 window.ZTaxiosURI = "http://localhost:9300";
-window.aiURI = "http://192.168.60.6:5000";
+window.aiURI = "http://192.168.60.6:4000";
 //倾斜模型高度配置
 window.modelBottomAltitude = 10;
 // 服务器ip