mirror of
https://github.com/NovaOSS/violet.git
synced 2024-11-25 16:44:00 +01:00
Added awesome STT and TTS features :)
This commit is contained in:
parent
d30d919358
commit
ce38f81115
|
@ -38,5 +38,6 @@ sudo apt-get install python3-pyaudio
|
|||
```
|
||||
|
||||
## Example tasks
|
||||
- what wifi am I connected with on Linux
|
||||
-
|
||||
- What WiFi am I connected with (on Linux)?
|
||||
- Tell me a short story!
|
||||
- Translate "Hello there"!
|
||||
|
|
|
@ -7,7 +7,7 @@ def ask() -> str:
|
|||
with sr.Microphone() as source2:
|
||||
recognizer.adjust_for_ambient_noise(source2, duration=1)
|
||||
recording = recognizer.listen(source2, timeout=5)
|
||||
return recognizer.recognize_google(recording, language='de-DE')
|
||||
return recognizer.recognize_google(recording, language='en-US') # lang.detect(text)[1]
|
||||
|
||||
except sr.RequestError:
|
||||
return 'I did not understand what you said.'
|
||||
|
|
|
@ -2,9 +2,13 @@ import os
|
|||
import gtts
|
||||
import playsound
|
||||
|
||||
def say(text):
|
||||
tts = gtts.gTTS(text=text, lang='de') #, lang='en'
|
||||
from . import lang
|
||||
|
||||
def say(text: str) -> None:
|
||||
"""Says a plain text using Google TTS."""
|
||||
tts = gtts.gTTS(text=text, lang=lang.detect(text)[0]) #, lang='en'
|
||||
filename = 'tts.temp.mp3'
|
||||
tts.save(filename)
|
||||
|
||||
playsound.playsound(filename)
|
||||
os.remove(filename)
|
||||
|
|
Loading…
Reference in a new issue