From a5e82050c018ddee550753879e884d3b61ca707f Mon Sep 17 00:00:00 2001 From: leon Date: Fri, 9 Dec 2022 17:49:37 +0800 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20=E5=AF=BC=E5=87=BA=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=90=8D=E6=B7=BB=E5=8A=A0=E5=9C=BA=E6=99=AF=E5=92=8C?= =?UTF-8?q?=E4=BA=91=E6=9C=8D=E5=8A=A1=E5=95=86=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 9 ++---- src/layout/AppMain/Single.tsx | 56 +++++++++++++++++++---------------- src/utils/core.ts | 6 ++-- 3 files changed, 37 insertions(+), 34 deletions(-) diff --git a/README.md b/README.md index 54ecda1..7839796 100644 --- a/README.md +++ b/README.md @@ -26,24 +26,21 @@ 目前支持阿里云、讯飞,其他平台陆续加入。 -**如果觉得不错,来个 star 支持下作者吧!你的 Star 是我更新代码的动力!:)** +`如果觉得不错,来个 star 支持下作者吧!你的 Star 是我更新代码的动力!:)` 想任何想吐槽或者建议的都可以直接飞个 [issue](https://github.com/funnyzak/tts-now/issues). -**下一步** +## TODO - [ ] 接入百度云 - [ ] 接入腾讯云 -- [ ] 导出标记合成配置 - -**已完成** - - [x] 增加升级更新提示 - [x] 配置框增加清除配置按钮 ## 目录 - [云语音合成助手](#云语音合成助手) + - [TODO](#todo) - [目录](#目录) - [发布](#发布) - [平台](#平台) diff --git a/src/layout/AppMain/Single.tsx b/src/layout/AppMain/Single.tsx index d3722e2..c653970 100644 --- a/src/layout/AppMain/Single.tsx +++ b/src/layout/AppMain/Single.tsx @@ -7,7 +7,9 @@ import { LoadingOutlined, PlayCircleOutlined } from '@ant-design/icons' -import { Button, Form, Input, message, Space } from 'antd' +import { + Button, Form, Input, message, Space +} from 'antd' import ReactAudioPlayer from 'react-audio-player' import useAppSetting from '@/hook/app' import { TtsFileStatus } from '@/type/enums' @@ -41,13 +43,12 @@ const singleTxtStyle = { const Index = () => { const { appSetting, setAppSetting } = useAppSetting() - const getSingleTxt = () => - appSetting.customSetting.singleTxt && - appSetting.customSetting.singleTxt !== null && - appSetting.customSetting.singleTxt.length > 0 && - core.currentSpeaker(appSetting).text !== appSetting.customSetting.singleTxt - ? appSetting.customSetting.singleTxt - : core.currentSpeaker(appSetting).text + const getSingleTxt = () => (appSetting.customSetting.singleTxt + && appSetting.customSetting.singleTxt !== null + && appSetting.customSetting.singleTxt.length > 0 + && core.currentSpeaker(appSetting).text !== appSetting.customSetting.singleTxt + ? appSetting.customSetting.singleTxt + : core.currentSpeaker(appSetting).text) const [singleTxt] = useState(getSingleTxt()) const singleFormRef: any = useRef(null) @@ -84,8 +85,8 @@ const Index = () => { message.error('请设置合成内容') } if ( - singleTtsFile?.status && - singleTtsFile?.status === TtsFileStatus.PROCESS + singleTtsFile?.status + && singleTtsFile?.status === TtsFileStatus.PROCESS ) { message.warning('正在准备播放..') } @@ -109,9 +110,9 @@ const Index = () => { const exportHandle = () => { if ( - !singleTtsFile || - core.isNullOrEmpty(singleTtsFile) || - core.isNullOrEmpty(singleTtsFile.audioUrl) + !singleTtsFile + || core.isNullOrEmpty(singleTtsFile) + || core.isNullOrEmpty(singleTtsFile.audioUrl) ) { message.error('没有可导出的内容') return @@ -119,10 +120,11 @@ const Index = () => { core.selectDirection('select_export_path', (outPath) => { singleTtsFile.savePath = outPath - singleTtsFile.saveName = `${singleTtsFile.textContent.substring( - 0, - 7 - )}_${new Date().getTime()}.${singleTtsFile.ttsSetting?.format || 'mp3'}` + singleTtsFile.saveName = `${appSetting.ttsSetting.engine.toString()}_${ + core.currentSpeaker(appSetting).speaker + }_${singleTtsFile.textContent.substring(0, 7)}_${new Date().getTime()}.${ + singleTtsFile.ttsSetting?.format || 'mp3' + }` setSingleTtsFile(singleTtsFile) core.exportAudioFile(singleTtsFile) }) @@ -130,9 +132,9 @@ const Index = () => { useEffect(() => { if ( - singleFormRef && - singleFormRef.current !== null && - singleFormRef.current !== undefined + singleFormRef + && singleFormRef.current !== null + && singleFormRef.current !== undefined ) { singleFormRef.current.setFieldsValue({ singleTxt: getSingleTxt() }) setSingleTtsFile({ @@ -157,18 +159,20 @@ const Index = () => { }} size="large" icon={processing ? : } - onClick={playHandle}> + onClick={playHandle} + > 立即播放 - {!singleTtsFile || - core.isNullOrEmpty(singleTtsFile) || - core.isNullOrEmpty(singleTtsFile.audioUrl) ? null : ( + {!singleTtsFile + || core.isNullOrEmpty(singleTtsFile) + || core.isNullOrEmpty(singleTtsFile.audioUrl) ? null : ( <> { ref={(el) => setAudioPlayer(el)} /> - )} + )} diff --git a/src/utils/core.ts b/src/utils/core.ts index e3e5dc3..edaa549 100644 --- a/src/utils/core.ts +++ b/src/utils/core.ts @@ -97,7 +97,7 @@ export const checkDirExist = ( ): boolean => { if (!fs.existsSync(_path || '')) { if (_tipIfNoExists) { - message.warning(_tipIfNoExists) + message.warning(_tipIfNoExists) } return false } @@ -347,7 +347,9 @@ export const ttsTasksRun = async ( _info.wordCount = _info.textContent.length _info.ttsStart = new Date().getTime() _info.savePath = appSetting.customSetting.savePath - _info.saveName = `${ + _info.saveName = `${appSetting.ttsSetting.engine.toString()}_${ + currentSpeaker(appSetting).speaker + }_${ _info.fileName?.split('.')[0] }_${new Date().getTime()}.${_info.ttsSetting.format}` return _info From 049dce10850ad3e6918e1b2e5a1ecf9edb5c9dc1 Mon Sep 17 00:00:00 2001 From: leon Date: Fri, 9 Dec 2022 17:50:30 +0800 Subject: [PATCH 2/2] chore: version code --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cee59d6..cedf539 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tts-now", - "version": "1.0.5", + "version": "1.0.6", "description": "tts assastant", "main": "build/bundle/main.js", "scripts": {