From 5b9e59bc07dd76320354f2af6be29f16dbcb21e7 Mon Sep 17 00:00:00 2001 From: Nicholas Albion Date: Thu, 1 Jun 2023 22:45:00 +1000 Subject: [PATCH] `speak` scripts for Windows --- examples/talk-llama/README.md | 4 ++-- examples/talk-llama/{speak.sh => speak} | 0 examples/talk-llama/speak.bat | 1 + examples/talk-llama/speak.ps1 | 12 ++++++++++++ examples/talk-llama/talk-llama.cpp | 2 +- examples/talk/README.md | 4 ++-- examples/talk/{speak.sh => speak} | 2 +- examples/talk/speak.bat | 1 + examples/talk/speak.ps1 | 12 ++++++++++++ examples/talk/talk.cpp | 2 +- 10 files changed, 33 insertions(+), 7 deletions(-) rename examples/talk-llama/{speak.sh => speak} (100%) mode change 100755 => 100644 create mode 100644 examples/talk-llama/speak.bat create mode 100644 examples/talk-llama/speak.ps1 rename examples/talk/{speak.sh => speak} (91%) mode change 100755 => 100644 create mode 100644 examples/talk/speak.bat create mode 100644 examples/talk/speak.ps1 diff --git a/examples/talk-llama/README.md b/examples/talk-llama/README.md index 295bc4d..01f696d 100644 --- a/examples/talk-llama/README.md +++ b/examples/talk-llama/README.md @@ -42,8 +42,8 @@ Example usage: ## TTS For best experience, this example needs a TTS tool to convert the generated text responses to voice. -You can use any TTS engine that you would like - simply edit the [speak.sh](speak.sh) script to your needs. -By default, it is configured to use MacOS's `say`, but you can use whatever you wish. +You can use any TTS engine that you would like - simply edit the [speak](speak) script to your needs. +By default, it is configured to use MacOS's `say` or Windows SpeechSynthesizer, but you can use whatever you wish. ## Discussion diff --git a/examples/talk-llama/speak.sh b/examples/talk-llama/speak old mode 100755 new mode 100644 similarity index 100% rename from examples/talk-llama/speak.sh rename to examples/talk-llama/speak diff --git a/examples/talk-llama/speak.bat b/examples/talk-llama/speak.bat new file mode 100644 index 0000000..d719d69 --- /dev/null +++ b/examples/talk-llama/speak.bat @@ -0,0 +1 @@ +@powershell -ExecutionPolicy Bypass -F examples\talk\speak.ps1 %1 %2 diff --git a/examples/talk-llama/speak.ps1 b/examples/talk-llama/speak.ps1 new file mode 100644 index 0000000..bdc4c5f --- /dev/null +++ b/examples/talk-llama/speak.ps1 @@ -0,0 +1,12 @@ +# Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser +param( + # voice options are David or Zira + [Parameter(Mandatory=$true)][string]$voice, + [Parameter(Mandatory=$true)][string]$text +) + +Add-Type -AssemblyName System.Speech; +$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer; +$speak.SelectVoice("Microsoft $voice Desktop"); +$speak.Rate="0"; +$speak.Speak($text); diff --git a/examples/talk-llama/talk-llama.cpp b/examples/talk-llama/talk-llama.cpp index cdeb2d9..57a02ea 100644 --- a/examples/talk-llama/talk-llama.cpp +++ b/examples/talk-llama/talk-llama.cpp @@ -47,7 +47,7 @@ struct whisper_params { std::string language = "en"; std::string model_wsp = "models/ggml-base.en.bin"; std::string model_llama = "models/ggml-llama-7B.bin"; - std::string speak = "./examples/talk-llama/speak.sh"; + std::string speak = "./examples/talk-llama/speak"; std::string prompt = ""; std::string fname_out; std::string path_session = ""; // path to file for saving/loading model eval state diff --git a/examples/talk/README.md b/examples/talk/README.md index 818a428..fe85795 100644 --- a/examples/talk/README.md +++ b/examples/talk/README.md @@ -37,5 +37,5 @@ wget --quiet --show-progress -O models/ggml-gpt-2-117M.bin https://huggingface.c ## TTS For best experience, this example needs a TTS tool to convert the generated text responses to voice. -You can use any TTS engine that you would like - simply edit the [speak.sh](speak.sh) script to your needs. -By default, it is configured to use `espeak`, but you can use whatever you wish. +You can use any TTS engine that you would like - simply edit the [speak](speak) script to your needs. +By default, it is configured to use MacOS's `say` or `espeak` or Windows SpeechSynthesizer, but you can use whatever you wish. diff --git a/examples/talk/speak.sh b/examples/talk/speak old mode 100755 new mode 100644 similarity index 91% rename from examples/talk/speak.sh rename to examples/talk/speak index f6954d1..b822f61 --- a/examples/talk/speak.sh +++ b/examples/talk/speak @@ -15,7 +15,7 @@ say "$2" # Eleven Labs # To use it, install the elevenlabs module from pip (pip install elevenlabs) # It's possible to use the API for free with limited number of characters. To increase this limit register to https://beta.elevenlabs.io to get an api key and paste it after 'ELEVEN_API_KEY=' -#Keep the line commented to use the free version whitout api key +#Keep the line commented to use the free version without api key # #export ELEVEN_API_KEY=your_api_key #wd=$(dirname $0) diff --git a/examples/talk/speak.bat b/examples/talk/speak.bat new file mode 100644 index 0000000..d719d69 --- /dev/null +++ b/examples/talk/speak.bat @@ -0,0 +1 @@ +@powershell -ExecutionPolicy Bypass -F examples\talk\speak.ps1 %1 %2 diff --git a/examples/talk/speak.ps1 b/examples/talk/speak.ps1 new file mode 100644 index 0000000..bdc4c5f --- /dev/null +++ b/examples/talk/speak.ps1 @@ -0,0 +1,12 @@ +# Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope CurrentUser +param( + # voice options are David or Zira + [Parameter(Mandatory=$true)][string]$voice, + [Parameter(Mandatory=$true)][string]$text +) + +Add-Type -AssemblyName System.Speech; +$speak = New-Object System.Speech.Synthesis.SpeechSynthesizer; +$speak.SelectVoice("Microsoft $voice Desktop"); +$speak.Rate="0"; +$speak.Speak($text); diff --git a/examples/talk/talk.cpp b/examples/talk/talk.cpp index 0def644..651ca20 100644 --- a/examples/talk/talk.cpp +++ b/examples/talk/talk.cpp @@ -36,7 +36,7 @@ struct whisper_params { std::string language = "en"; std::string model_wsp = "models/ggml-base.en.bin"; std::string model_gpt = "models/ggml-gpt-2-117M.bin"; - std::string speak = "./examples/talk/speak.sh"; + std::string speak = "./examples/talk/speak"; std::string fname_out; };