mirror of
https://github.com/NovaOSS/violet.git
synced 2024-11-25 18:33:58 +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
|
## 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:
|
with sr.Microphone() as source2:
|
||||||
recognizer.adjust_for_ambient_noise(source2, duration=1)
|
recognizer.adjust_for_ambient_noise(source2, duration=1)
|
||||||
recording = recognizer.listen(source2, timeout=5)
|
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:
|
except sr.RequestError:
|
||||||
return 'I did not understand what you said.'
|
return 'I did not understand what you said.'
|
||||||
|
|
|
@ -2,9 +2,13 @@ import os
|
||||||
import gtts
|
import gtts
|
||||||
import playsound
|
import playsound
|
||||||
|
|
||||||
def say(text):
|
from . import lang
|
||||||
tts = gtts.gTTS(text=text, lang='de') #, lang='en'
|
|
||||||
|
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'
|
filename = 'tts.temp.mp3'
|
||||||
tts.save(filename)
|
tts.save(filename)
|
||||||
|
|
||||||
playsound.playsound(filename)
|
playsound.playsound(filename)
|
||||||
os.remove(filename)
|
os.remove(filename)
|
||||||
|
|
Loading…
Reference in a new issue