瀏覽代碼

搜索类型

ZaiZai 2 年之前
父節點
當前提交
58a08a7c22
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      src/views/using/query.vue

+ 4 - 3
src/views/using/query.vue

@@ -1542,11 +1542,12 @@ const startRecorder = (stream) => {
     // 录音结束
     mediaRecorder.addEventListener("stop", () => {
         //获取wav格式音频数据
-        let blob = new Blob([chunks], {type: "audio/webm;codecs=opus"});
-        let file = new window.File([blob],new Date().getTime() + ".webm", {type: "audio/webm;codecs=opus"});
+        let blob = new Blob([chunks], {type: "audio/wav;codecs=opus"});
+        let file = new window.File([blob],new Date().getTime() + ".wav", {type: "audio/wav;codecs=opus"});
         testDownload(blob)
         //准备上传
         const formData = new FormData()
+        console.log('file', file)
         formData.append('file', file)
         transcribeApi(formData)
     });
@@ -1560,7 +1561,7 @@ const testDownload = (blob) => {
     let link = document.createElement("a");
     link.href = url;
     // 把上面获得的blob的对象链接赋值给新创建的这个 a 链接
-    link.setAttribute("download", "录音.webm");
+    link.setAttribute("download", "录音.wav");
     // 设置下载的属性(所以使用的是download),这个是a 标签的一个属性
     // 后面的是文件名字,可以更改
     link.click();