-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
37f94a7
commit e3d293a
Showing
6 changed files
with
71 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
const { spawn } = require('node:child_process') | ||
|
||
let ttsPromise = (text, audioPath, SpeechSynthesisVoiceName = 'zh-CN-XiaoyiNeural')=>{ | ||
let vttPath = audioPath + '.vtt' | ||
return new Promise((resolve, reject)=>{ | ||
const spawned = spawn('edge-tts', [ | ||
'-v', SpeechSynthesisVoiceName, '--text', text, '--write-media', audioPath, '--write-subtitles', vttPath | ||
]) | ||
spawned.on('error', data=>{ | ||
reject(data) | ||
}) | ||
spawned.on('exit', code=>{ | ||
if (code === 0) { | ||
return resolve(vttPath) | ||
} | ||
return reject('close code is ' + code) | ||
}) | ||
}) | ||
} | ||
|
||
module.exports = { | ||
ttsPromise | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters