mirror of
https://github.com/tcsenpai/agenticSeek.git
synced 2025-06-07 11:35:29 +00:00
feat : improve tts test code at bottom of file & index safety
This commit is contained in:
parent
92e2e8c0d6
commit
f70606b5ec
@ -8,6 +8,11 @@ from kokoro import KPipeline
|
|||||||
from IPython.display import display, Audio
|
from IPython.display import display, Audio
|
||||||
import soundfile as sf
|
import soundfile as sf
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
from utility import pretty_print, animate_thinking
|
||||||
|
else:
|
||||||
|
from sources.utility import pretty_print, animate_thinking
|
||||||
|
|
||||||
class Speech():
|
class Speech():
|
||||||
"""
|
"""
|
||||||
Speech is a class for generating speech from text.
|
Speech is a class for generating speech from text.
|
||||||
@ -41,6 +46,10 @@ class Speech():
|
|||||||
if not self.pipeline:
|
if not self.pipeline:
|
||||||
return
|
return
|
||||||
sentence = self.clean_sentence(sentence)
|
sentence = self.clean_sentence(sentence)
|
||||||
|
print("using voice: ", self.voice)
|
||||||
|
if voice_number >= len(self.voice_map[self.language]) or voice_number < 0:
|
||||||
|
pretty_print("Invalid voice number, using default voice", color="error")
|
||||||
|
voice_number = 0
|
||||||
self.voice = self.voice_map[self.language][voice_number]
|
self.voice = self.voice_map[self.language][voice_number]
|
||||||
generator = self.pipeline(
|
generator = self.pipeline(
|
||||||
sentence, voice=self.voice,
|
sentence, voice=self.voice,
|
||||||
@ -123,12 +132,18 @@ class Speech():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
speech = Speech()
|
speech = Speech()
|
||||||
tosay = """
|
tosay_en = """
|
||||||
I looked up recent news using the website https://www.theguardian.com/world
|
I looked up recent news using the website https://www.theguardian.com/world
|
||||||
Here is how to list files:
|
|
||||||
ls -l -a -h
|
|
||||||
the ip address of the server is 192.168.1.1
|
|
||||||
"""
|
"""
|
||||||
for voice_idx in range (len(speech.voice_map["english"])):
|
tosay_zh = """
|
||||||
print(f"Voice {voice_idx}")
|
我使用网站 https://www.theguardian.com/world 查阅了最近的新闻。
|
||||||
speech.speak(tosay, voice_idx)
|
"""
|
||||||
|
tosay_fr = """
|
||||||
|
J'ai consulté les dernières nouvelles sur le site https://www.theguardian.com/world
|
||||||
|
"""
|
||||||
|
spk = Speech(enable=True, language="en", voice_idx=0)
|
||||||
|
spk.speak(tosay_en)
|
||||||
|
spk = Speech(enable=True, language="fr", voice_idx=0)
|
||||||
|
spk.speak(tosay_fr)
|
||||||
|
spk = Speech(enable=True, language="zh", voice_idx=0)
|
||||||
|
spk.speak(tosay_zh)
|
Loading…
x
Reference in New Issue
Block a user