Skip to content

Commit

Permalink
update sox and edge-tts
Browse files Browse the repository at this point in the history
  • Loading branch information
SchneeHertz committed Aug 15, 2023
1 parent ae176ff commit f57b49f
Show file tree
Hide file tree
Showing 10 changed files with 909 additions and 1,503 deletions.
11 changes: 9 additions & 2 deletions modules/edge-tts.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
const { spawn } = require('node:child_process')
const { config } = require('../utils/initFile.js')

const edgeTTS = path.join(process.cwd(), 'resources/extraResources/edge-tts.exe')

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
const spawned = spawn(edgeTTS, [
'-v', SpeechSynthesisVoiceName,
'--text', text,
'--write-media', audioPath,
'--write-subtitles', vttPath,
'--proxy', config.proxy
])
spawned.on('error', data=>{
reject(data)
Expand Down
4 changes: 2 additions & 2 deletions modules/speech.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ const fs = require('node:fs')
const path = require('node:path')
const { nanoid } = require('nanoid')


const sox = path.join(process.cwd(), 'resources/extraResources/sox.exe')
let recordPromise = (SPEECH_AUDIO_PATH)=>{
let audioFilePath = path.join(SPEECH_AUDIO_PATH, nanoid() + '.mp3')
return new Promise((resolve, reject)=>{
const spawned = spawn('sox', ['-d', '-t', 'mp3', audioFilePath, 'silence', '1', '0.1', '3%', '1', '3.0', '3%'])
const spawned = spawn(sox, ['-d', '-t', 'mp3', audioFilePath, 'silence', '1', '0.1', '3%', '1', '3.0', '3%'])
spawned.on('error', data=>{
reject(data)
})
Expand Down
Empty file added modules/whisper.js
Empty file.

0 comments on commit f57b49f

Please sign in to comment.