mirror of
https://github.com/NovaOSS/violet.git
synced 2024-11-25 17:43: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
|
## Example tasks
|
||||||
- What WiFi am I connected with (on Linux)?
|
- What WiFi am I connected with (on Linux)?
|
||||||
- Tell me a short story!
|
- Tell me a short story!
|
||||||
- Translate "Hello there"!
|
- Translate "Hello there" into Spanish!
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
gtts
|
gtts
|
||||||
openai
|
openai
|
||||||
pyaudio
|
# pyaudio
|
||||||
colorama
|
colorama
|
||||||
playsound
|
playsound
|
||||||
langdetect
|
# langdetect
|
||||||
speechrecognition
|
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
|
import langdetect
|
||||||
|
|
||||||
LANGS = {
|
LANGS = {
|
||||||
|
@ -8,10 +10,10 @@ LANGS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
def detect(text: str):
|
def detect(text: str):
|
||||||
detected = langdetect.detect(text)
|
# detected = langdetect.detect(text)
|
||||||
|
|
||||||
for lang in LANGS:
|
# for lang in LANGS:
|
||||||
if lang == detected:
|
# if lang == detected:
|
||||||
return [lang, LANGS[lang]]
|
# return [lang, LANGS[lang]]
|
||||||
|
|
||||||
return 'en-US'
|
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?
|
AI: I am an AI created by OpenAI. How can I help you today?
|
||||||
Human: What's the current time?
|
Human: What's the current time?
|
||||||
AI: ```
|
AI: ```
|
||||||
import time
|
import datetime
|
||||||
|
|
||||||
current_time = time.localtime()
|
|
||||||
current_time = time.strftime("%H:%M:%S", current_time)
|
|
||||||
|
|
||||||
|
current_time = datetime.datetime.now().strftime("%I:%M %p")
|
||||||
print(f"The current time is {current_time}.")
|
print(f"The current time is {current_time}.")
|
||||||
```
|
```
|
||||||
Human: Thanks. Please create a file called "todo.txt" and save "Read a book" in it."
|
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: ```
|
AI: ```
|
||||||
print(f"{3**4+6*5}")
|
print(f"{3**4+6*5}")
|
||||||
```
|
```
|
||||||
Human: Fass mir Harry Potter in 2 Sätze zusammen.
|
Human: Tell me a short story.
|
||||||
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.
|
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: Was ist 2 plus 3 mal 5
|
Human: Start Discord.
|
||||||
AI: 17
|
AI:
|
||||||
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.
|
|
|
@ -1,16 +1,20 @@
|
||||||
import speech_recognition as sr
|
import colorama
|
||||||
|
import speech_recognition
|
||||||
|
|
||||||
recognizer = sr.Recognizer()
|
recognizer = speech_recognition.Recognizer()
|
||||||
|
|
||||||
def ask() -> str:
|
def ask() -> str:
|
||||||
try:
|
try:
|
||||||
with sr.Microphone() as source2:
|
with speech_recognition.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='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.'
|
return 'I did not understand what you said.'
|
||||||
|
|
||||||
except sr.UnknownValueError:
|
except speech_recognition.UnknownValueError:
|
||||||
return 'There was an error processing what you said.'
|
return 'There was an error processing what you said.'
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
import os
|
import os
|
||||||
import gtts
|
import gtts
|
||||||
|
import colorama
|
||||||
import playsound
|
import playsound
|
||||||
|
|
||||||
from . import lang
|
from . import lang
|
||||||
|
|
||||||
def say(text: str) -> None:
|
def say(text: str) -> None:
|
||||||
"""Says a plain text using Google TTS."""
|
"""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'
|
filename = 'tts.temp.mp3'
|
||||||
tts.save(filename)
|
tts.save(filename)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue