From b803224532822ff82fab94d7c3a5067d8913a1e4 Mon Sep 17 00:00:00 2001 From: liugaowei Date: Tue, 18 Apr 2023 13:09:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B01.9.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + .vscode/settings.json | 9 +- electron/main/index.ts | 9 +- electron/utils/api.ts | 50 + package-lock.json | 15 +- package.json | 2 +- src/components/footer/Footer.vue | 2 +- src/store/play.ts | 131 +- yarn.lock | 4620 +++++++++++++++--------------- 9 files changed, 2325 insertions(+), 2514 deletions(-) create mode 100644 electron/utils/api.ts diff --git a/.gitignore b/.gitignore index b4fa623..02f2500 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ dist-ssr release .vscode/.debug.env +.vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json index 894b714..214a406 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,4 +1,11 @@ { "typescript.tsdk": "node_modules/typescript/lib", "typescript.enablePromptUseWorkspaceTsdk": true, -} \ No newline at end of file + "cSpell.words": [ + "customvoiceconnectionid", + "KHTML", + "mstts", + "southeastasia", + "ssml" + ] +} diff --git a/electron/main/index.ts b/electron/main/index.ts index bac2db1..a4c7315 100644 --- a/electron/main/index.ts +++ b/electron/main/index.ts @@ -1,6 +1,7 @@ import { app, BrowserWindow, shell, ipcMain } from "electron"; import { release } from "os"; import { join } from "path"; +import api from "../utils/api"; import logger from "../utils/log"; @@ -164,4 +165,10 @@ ipcMain.on("openDevTools", async (event, arg) => { // Get desktop path ipcMain.on("getDesktopPath", async (event) => { event.returnValue = app.getPath("desktop"); -}); \ No newline at end of file +}); + +// Get desktop path +ipcMain.handle("speech", async (event, ssml) => { + const res = api.speechApi(ssml); + return res; +}); diff --git a/electron/utils/api.ts b/electron/utils/api.ts new file mode 100644 index 0000000..246d216 --- /dev/null +++ b/electron/utils/api.ts @@ -0,0 +1,50 @@ +var axios = require("axios");const fs = require("fs"); + +const speechApi = (ssml: string) => { + var data = JSON.stringify({ + ssml, + ttsAudioFormat: "audio-24khz-160kbitrate-mono-mp3", + offsetInPlainText: 0, + properties: { + SpeakTriggerSource: "AccTuningPagePlayButton", + }, + }); + + var config = { + method: "post", + url: "https://southeastasia.api.speech.microsoft.com/accfreetrial/texttospeech/acc/v3.0-beta1/vcg/speak", + responseType: "arraybuffer", + headers: { + authority: "southeastasia.api.speech.microsoft.com", + accept: "*/*", + "accept-language": "zh-CN,zh;q=0.9", + customvoiceconnectionid: "d8a3a480-dd87-11ed-8758-97b5a7fbfaf6", + origin: "https://speech.microsoft.com", + "sec-ch-ua": + '"Google Chrome";v="111", "Not(A:Brand";v="8", "Chromium";v="111"', + "sec-ch-ua-mobile": "?0", + "sec-ch-ua-platform": '"Windows"', + "sec-fetch-dest": "empty", + "sec-fetch-mode": "cors", + "sec-fetch-site": "same-site", + "user-agent": + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36", + "content-type": "application/json", + }, + + data: data, + }; + + return new Promise((resolve, reject) => { + axios(config) + .then(function (response) { + resolve(response.data); + }) + .catch(function (error) { + reject(error); + }); + }); +}; +export default { + speechApi, +}; diff --git a/package-lock.json b/package-lock.json index 7ff9993..55fbc4f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,16 @@ { "name": "tts-vue", - "version": "1.5.0", + "version": "1.8.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "tts-vue", - "version": "1.5.0", + "version": "1.8.8", "license": "MIT", "dependencies": { "axios": "^0.27.2", + "electron-log": "^4.4.8", "electron-store": "^8.0.2", "element-plus": "2.2.9", "nodejs-websocket": "^1.7.2", @@ -1860,6 +1861,11 @@ "node": ">= 10.0.0" } }, + "node_modules/electron-log": { + "version": "4.4.8", + "resolved": "https://registry.npmmirror.com/electron-log/-/electron-log-4.4.8.tgz", + "integrity": "sha512-QQ4GvrXO+HkgqqEOYbi+DHL7hj5JM+nHi/j+qrN9zeeXVKy8ZABgbu4CnG+BBqDZ2+tbeq9tUC4DZfIWFU5AZA==" + }, "node_modules/electron-osx-sign": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/electron-osx-sign/-/electron-osx-sign-0.6.0.tgz", @@ -6123,6 +6129,11 @@ } } }, + "electron-log": { + "version": "4.4.8", + "resolved": "https://registry.npmmirror.com/electron-log/-/electron-log-4.4.8.tgz", + "integrity": "sha512-QQ4GvrXO+HkgqqEOYbi+DHL7hj5JM+nHi/j+qrN9zeeXVKy8ZABgbu4CnG+BBqDZ2+tbeq9tUC4DZfIWFU5AZA==" + }, "electron-osx-sign": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/electron-osx-sign/-/electron-osx-sign-0.6.0.tgz", diff --git a/package.json b/package.json index 1622d4d..5b86169 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tts-vue", - "version": "1.8.8", + "version": "1.9.0", "main": "dist/electron/main/index.js", "description": "🎤 微软语音合成工具,使用 Electron + Vue + ElementPlus + Vite 构建。", "author": "沫離Loker ", diff --git a/src/components/footer/Footer.vue b/src/components/footer/Footer.vue index 52812c8..7d1bbe1 100644 --- a/src/components/footer/Footer.vue +++ b/src/components/footer/Footer.vue @@ -27,7 +27,7 @@