|
@@ -418,10 +418,6 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</HcDialog>
|
|
|
-
|
|
|
- <audio id="testAudio" controls style="position: absolute;top: 0;left: 40%;">
|
|
|
- <source type="audio/wav">
|
|
|
- </audio>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -429,7 +425,7 @@
|
|
|
import {ref, nextTick, onMounted, watch} from "vue";
|
|
|
import {useAppStore} from "~src/store";
|
|
|
import MetaTable from "../transfer/components/meta-table.vue"
|
|
|
-import {getArrValue, arrIndex, isArrIndex, isString} from "js-fast-way"
|
|
|
+import {getArrValue, arrIndex, isArrIndex} from "js-fast-way"
|
|
|
import archiveQueryApi from "~api/using/query.js";
|
|
|
import tuningApi from "~api/archiveConfig/tuning.js";
|
|
|
import imageViewGui from "~src/assets/view/gui.png";
|
|
@@ -1532,27 +1528,33 @@ const transcribeClick = async () => {
|
|
|
|
|
|
//开始录音
|
|
|
const startRecorder = (stream) => {
|
|
|
- let mediaRecorder = new MediaRecorder(stream);
|
|
|
+ let mediaRecorder = new MediaRecorder(stream), chunks;
|
|
|
mediaRecorderRef.value = mediaRecorder
|
|
|
//开始录音
|
|
|
mediaRecorder.start();
|
|
|
setMicTimeFormat() //开始计时
|
|
|
// 录音结束时,停止并下载录音文件
|
|
|
- mediaRecorder.addEventListener("dataavailable", event => {
|
|
|
+ mediaRecorder.addEventListener("dataavailable", (e) => {
|
|
|
+ chunks = e.data;
|
|
|
+ console.log(e.data)
|
|
|
+ console.log(e)
|
|
|
+ });
|
|
|
+ // 录音结束
|
|
|
+ mediaRecorder.addEventListener("stop", () => {
|
|
|
clearTimeout(micTimeRef.value);
|
|
|
micTimeRef.value = null
|
|
|
- let audioFile = new Blob([event.data], { type: "audio/wav" });
|
|
|
- const dom = document.getElementById("testAudio")
|
|
|
- dom.src = URL.createObjectURL(audioFile);
|
|
|
- dom.play()
|
|
|
- transcribeApi(audioFile)
|
|
|
+ //获取wav格式音频数据
|
|
|
+ let blob = new Blob([chunks], {type: "audio/webm;codecs=opus"});
|
|
|
+ let file = new window.File([blob],new Date().getTime() + ".webm");
|
|
|
+ //准备上传
|
|
|
+ const formData = new FormData()
|
|
|
+ formData.append('file', file)
|
|
|
+ transcribeApi(formData)
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//发起请求
|
|
|
-const transcribeApi = async (file) => {
|
|
|
- let formData = new FormData();
|
|
|
- formData.append("file", file);
|
|
|
+const transcribeApi = async (formData) => {
|
|
|
const { error, code, data } = await archiveQueryApi.micSearchInfo(formData)
|
|
|
/*const str = isString(data) ? data : ''
|
|
|
if (!error && code === 200 && str) {
|