Skip to content

Commit

Permalink
Merge pull request #74 from funnyzak/feat/output_file_name
Browse files Browse the repository at this point in the history
  • Loading branch information
funnyzak committed Dec 9, 2022
2 parents a1c5ca2 + 049dce1 commit 33ac5a4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,21 @@

目前支持阿里云、讯飞,其他平台陆续加入。

**如果觉得不错,来个 star 支持下作者吧!你的 Star 是我更新代码的动力!:)**
`如果觉得不错,来个 star 支持下作者吧!你的 Star 是我更新代码的动力!:)`

想任何想吐槽或者建议的都可以直接飞个 [issue](https://github.com/funnyzak/tts-now/issues).

**下一步**
## TODO

- [ ] 接入百度云
- [ ] 接入腾讯云
- [ ] 导出标记合成配置

**已完成**

- [x] 增加升级更新提示
- [x] 配置框增加清除配置按钮

## 目录

- [云语音合成助手](#云语音合成助手)
- [TODO](#todo)
- [目录](#目录)
- [发布](#发布)
- [平台](#平台)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tts-now",
"version": "1.0.5",
"version": "1.0.6",
"description": "tts assastant",
"main": "build/bundle/main.js",
"scripts": {
Expand Down
56 changes: 30 additions & 26 deletions src/layout/AppMain/Single.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -84,8 +85,8 @@ const Index = () => {
message.error('请设置合成内容')
}
if (
singleTtsFile?.status &&
singleTtsFile?.status === TtsFileStatus.PROCESS
singleTtsFile?.status
&& singleTtsFile?.status === TtsFileStatus.PROCESS
) {
message.warning('正在准备播放..')
}
Expand All @@ -109,30 +110,31 @@ const Index = () => {

const exportHandle = () => {
if (
!singleTtsFile ||
core.isNullOrEmpty(singleTtsFile) ||
core.isNullOrEmpty(singleTtsFile.audioUrl)
!singleTtsFile
|| core.isNullOrEmpty(singleTtsFile)
|| core.isNullOrEmpty(singleTtsFile.audioUrl)
) {
message.error('没有可导出的内容')
return
}

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)
})
}

useEffect(() => {
if (
singleFormRef &&
singleFormRef.current !== null &&
singleFormRef.current !== undefined
singleFormRef
&& singleFormRef.current !== null
&& singleFormRef.current !== undefined
) {
singleFormRef.current.setFieldsValue({ singleTxt: getSingleTxt() })
setSingleTtsFile({
Expand All @@ -157,18 +159,20 @@ const Index = () => {
}}
size="large"
icon={processing ? <LoadingOutlined /> : <PlayCircleOutlined />}
onClick={playHandle}>
onClick={playHandle}
>
立即播放
</Button>
{!singleTtsFile ||
core.isNullOrEmpty(singleTtsFile) ||
core.isNullOrEmpty(singleTtsFile.audioUrl) ? null : (
{!singleTtsFile
|| core.isNullOrEmpty(singleTtsFile)
|| core.isNullOrEmpty(singleTtsFile.audioUrl) ? null : (
<>
<Button
type="primary"
size="large"
icon={<ExportOutlined />}
onClick={exportHandle}>
onClick={exportHandle}
>
导出
</Button>
<ReactAudioPlayer
Expand All @@ -180,7 +184,7 @@ const Index = () => {
ref={(el) => setAudioPlayer(el)}
/>
</>
)}
)}
</Space>
</div>
</div>
Expand Down
6 changes: 4 additions & 2 deletions src/utils/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export const checkDirExist = (
): boolean => {
if (!fs.existsSync(_path || '')) {
if (_tipIfNoExists) {
message.warning(_tipIfNoExists)
message.warning(_tipIfNoExists)
}
return false
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 33ac5a4

Please sign in to comment.