mirror of
https://github.com/NovaOSS/violet.git
synced 2024-11-25 15:33:58 +01:00
Improved stuff
This commit is contained in:
parent
ce38f81115
commit
1d62cdf758
|
@ -40,4 +40,4 @@ sudo apt-get install python3-pyaudio
|
|||
## Example tasks
|
||||
- What WiFi am I connected with (on Linux)?
|
||||
- Tell me a short story!
|
||||
- Translate "Hello there"!
|
||||
- Translate "Hello there" into Spanish!
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
gtts
|
||||
openai
|
||||
pyaudio
|
||||
# pyaudio
|
||||
colorama
|
||||
playsound
|
||||
langdetect
|
||||
# langdetect
|
||||
speechrecognition
|
0
sandbox/discord.py
Normal file
0
sandbox/discord.py
Normal file
19
test.py
Normal file
19
test.py
Normal file
|
@ -0,0 +1,19 @@
|
|||
# TODO Test this on Windows
|
||||
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
# Check the operating system
|
||||
os_name = platform.system()
|
||||
|
||||
# Set the Discord binary path based on the operating system
|
||||
if os_name == 'Windows':
|
||||
discord_path = 'C:\Program Files (x86)\Discord\Discord.exe'
|
||||
elif os_name == 'Darwin': # macOS
|
||||
discord_path = '/Applications/Discord.app/Contents/MacOS/Discord'
|
||||
else:
|
||||
# Assume Linux
|
||||
discord_path = '/usr/bin/discord'
|
||||
|
||||
# Open Discord using the default binary path
|
||||
subprocess.run([discord_path])
|
|
@ -1,3 +1,5 @@
|
|||
"""Language detection module. Currently not used, as langdetect is too inaccurate!"""
|
||||
|
||||
import langdetect
|
||||
|
||||
LANGS = {
|
||||
|
@ -8,10 +10,10 @@ LANGS = {
|
|||
}
|
||||
|
||||
def detect(text: str):
|
||||
detected = langdetect.detect(text)
|
||||
# detected = langdetect.detect(text)
|
||||
|
||||
for lang in LANGS:
|
||||
if lang == detected:
|
||||
return [lang, LANGS[lang]]
|
||||
# for lang in LANGS:
|
||||
# if lang == detected:
|
||||
# return [lang, LANGS[lang]]
|
||||
|
||||
return 'en-US'
|
||||
|
|
6
violet/model-german.txt
Normal file
6
violet/model-german.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
Human: Fass mir Harry Potter in 2 Sätze zusammen.
|
||||
AI: Harry Potter ist eine populäre Fantasy-Buchreihe und Filmreihe, die von J.K. Rowling geschrieben wurde. Die Geschichte dreht sich um den titelgebenden Helden Harry Potter, einen jungen Zauberer, der erfährt, dass er berühmt und berüchtigt ist und sich einer Reihe von Abenteuern stellen muss, während er versucht, den bösen Lord Voldemort zu besiegen und die Welt der Magie zu retten.
|
||||
Human: Was ist 2 plus 3 mal 5
|
||||
AI: 17
|
||||
Human: Was ist die Entfernung von Erde zu Mond?
|
||||
AI: Die durchschnittliche Entfernung von der Erde zum Mond beträgt etwa 384.400 Kilometer. Die Entfernung kann jedoch je nach der Position der Erde und des Mondes in ihren jeweiligen Umlaufbahnen variieren.
|
|
@ -7,11 +7,9 @@ Human: Hello, who are you?
|
|||
AI: I am an AI created by OpenAI. How can I help you today?
|
||||
Human: What's the current time?
|
||||
AI: ```
|
||||
import time
|
||||
|
||||
current_time = time.localtime()
|
||||
current_time = time.strftime("%H:%M:%S", current_time)
|
||||
import datetime
|
||||
|
||||
current_time = datetime.datetime.now().strftime("%I:%M %p")
|
||||
print(f"The current time is {current_time}.")
|
||||
```
|
||||
Human: Thanks. Please create a file called "todo.txt" and save "Read a book" in it."
|
||||
|
@ -40,9 +38,7 @@ Human: What's 3 to the power of 4 plus 6 multiplied by 5?
|
|||
AI: ```
|
||||
print(f"{3**4+6*5}")
|
||||
```
|
||||
Human: Fass mir Harry Potter in 2 Sätze zusammen.
|
||||
AI: Harry Potter ist eine populäre Fantasy-Buchreihe und Filmreihe, die von J.K. Rowling geschrieben wurde. Die Geschichte dreht sich um den titelgebenden Helden Harry Potter, einen jungen Zauberer, der erfährt, dass er berühmt und berüchtigt ist und sich einer Reihe von Abenteuern stellen muss, während er versucht, den bösen Lord Voldemort zu besiegen und die Welt der Magie zu retten.
|
||||
Human: Was ist 2 plus 3 mal 5
|
||||
AI: 17
|
||||
Human: Was ist die Entfernung von Erde zu Mond?
|
||||
AI: Die durchschnittliche Entfernung von der Erde zum Mond beträgt etwa 384.400 Kilometer. Die Entfernung kann jedoch je nach der Position der Erde und des Mondes in ihren jeweiligen Umlaufbahnen variieren.
|
||||
Human: Tell me a short story.
|
||||
AI: One day, a kind man named John helped a traveler in need. In return, the traveler gave John a magical stone that brought him good luck and happiness. John used its magic to help others, and the villagers learned to be more compassionate. The end.
|
||||
Human: Start Discord.
|
||||
AI:
|
|
@ -1,16 +1,20 @@
|
|||
import speech_recognition as sr
|
||||
import colorama
|
||||
import speech_recognition
|
||||
|
||||
recognizer = sr.Recognizer()
|
||||
recognizer = speech_recognition.Recognizer()
|
||||
|
||||
def ask() -> str:
|
||||
try:
|
||||
with sr.Microphone() as source2:
|
||||
with speech_recognition.Microphone() as source2:
|
||||
recognizer.adjust_for_ambient_noise(source2, duration=1)
|
||||
recording = recognizer.listen(source2, timeout=5)
|
||||
return recognizer.recognize_google(recording, language='en-US') # lang.detect(text)[1]
|
||||
|
||||
except sr.RequestError:
|
||||
recognized_text = recognizer.recognize_google(recording, language='en-US') # lang.detect(text)[1]
|
||||
print(f'{colorama.Fore.BLUE}[STT] {recognized_text}')
|
||||
return recognized_text
|
||||
|
||||
except speech_recognition.RequestError:
|
||||
return 'I did not understand what you said.'
|
||||
|
||||
except sr.UnknownValueError:
|
||||
except speech_recognition.UnknownValueError:
|
||||
return 'There was an error processing what you said.'
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
import os
|
||||
import gtts
|
||||
import colorama
|
||||
import playsound
|
||||
|
||||
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'
|
||||
# print(f'{colorama.Fore.YELLOW}[TTS] Detected language: {lang.detect(text)}')
|
||||
tts = gtts.gTTS(text=text, lang='en')
|
||||
filename = 'tts.temp.mp3'
|
||||
tts.save(filename)
|
||||
|
||||
|
|
Loading…
Reference in a new issue