From 9ad0e3cf961324f184ddca0634cbe71ec72265b6 Mon Sep 17 00:00:00 2001 From: Kodai Aoyama Date: Sat, 15 Jul 2023 01:58:10 +0900 Subject: [PATCH] fix --- README.md | 6 +++++- src/voicepeaky.nim | 31 ++++++++++++++++++++----------- voicepeaky.nimble | 2 +- 3 files changed, 26 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 005f5eb..85dae9f 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ brew upgrade voicepeaky ```sh # Install with wget or curl ## set the latest version on releases. -VERSION=v1.0.0 +VERSION=v1.0.1 ## set the OS you use. (macos) OS=linux ## case you use wget @@ -90,3 +90,7 @@ tar xvf ./voicepeaky${OS}.tar.gz ## move it to a location in your $PATH, such as /usr/local/bin. mv ./voicepeaky /usr/local/bin/ ``` + +## Note + +Voicepeak occasionally crashes; Voicepeaky will automatically retry, but if an error popup appears, please close it. diff --git a/src/voicepeaky.nim b/src/voicepeaky.nim index a1713e7..2edbbf1 100644 --- a/src/voicepeaky.nim +++ b/src/voicepeaky.nim @@ -57,24 +57,33 @@ proc pollingFiles() {.thread.} = for f in walkDir(workspace): files.add(f.path) files.sort(); - for file in files: + for i, file in files: let _ = execCmd("afplay " & file) - removeFile(file) + if i == files.len - 1: + removeFile(file) + else: + spawn removeFile(file) proc pollingSpeeches() {.thread.} = {.cast(gcsafe).}: while true: if speeches.len != 0: let speech = speeches.pop() - let _ = execCmd("/Applications/voicepeak.app/Contents/MacOS/voicepeak --say " & speech.text & - " --narrator \"" & speech.narrator & - "\" --emotion happy=" & $speech.happy & - ",fun=" & $speech.fun & - ",angry=" & $speech.fun & - ",sad=" & $speech.fun & - " --speed " & $speech.speed & - " --pitch " & $speech.pitch & - " --out " & workspace & "/" & $now() & ".wav") + let retryLimit = 2 + var count = 0 + while true: + count += 1 + let errCode = execCmd("/Applications/voicepeak.app/Contents/MacOS/voicepeak --say " & speech.text & + " --narrator \"" & speech.narrator & + "\" --emotion happy=" & $speech.happy & + ",fun=" & $speech.fun & + ",angry=" & $speech.fun & + ",sad=" & $speech.fun & + " --speed " & $speech.speed & + " --pitch " & $speech.pitch & + " --out " & workspace & "/" & $now() & ".wav &>/dev/null") + if errCode == 0 or count > retryLimit: + break; when isMainModule: if not dirExists(workspace): diff --git a/voicepeaky.nimble b/voicepeaky.nimble index 8fd621c..3aa6972 100644 --- a/voicepeaky.nimble +++ b/voicepeaky.nimble @@ -1,6 +1,6 @@ # Package -version = "1.0.0" +version = "1.0.1" author = "solaoi" description = "Voicepeak Server" license = "MIT"