main
samerbam 1 year ago
commit 15d1a0b58b

16
ai.py

@ -0,0 +1,16 @@
from revChatGPT.V1 import Chatbot
chatbot = Chatbot(config={
"email": "pushes_mouthy_0x@icloud.com",
"password": "9hCyLiGWUdr9MX2mepTk"
})
prompt = "how many beaches does portugal have?"
response = ""
for data in chatbot.ask(
prompt
):
response = data["message"]
print(response)

@ -0,0 +1,24 @@
import time
import speech_recognition as sr
def callback(recognizer, audio):
try:
print("Processing...")
text = r.recognize_whisper(audio, language="english")
print(f"Apollo (Whisper Model) thinks you said: {text}")
except sr.UnknownValueError:
print("Could not understand audio.")
except sr.RequestError as e:
print("Could not request result from Whisper")
r = sr.Recognizer()
m = sr.Microphone()
with m as source:
r.adjust_for_ambient_noise(source)
stop_listening = r.listen_in_background(m, callback)
print("Listening...")
while True:
time.sleep(0.1)

@ -0,0 +1,20 @@
#Switch to virtual python enviroment
source .venv/bin/activate
#install homebrew (https://brew.sh)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
#Install brew dependencies
brew install portaudio
brew install ffmpeg
# Install python dependencies
pip install -U pyaudio # Microphone
pip install numpy
pip install pillow
pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cpu
pip install -U openai-whisper # Speech to text model (needed by speechrecognition)
pip install -U SpeechRecognition # Speech to text logic
pip install -U revChatGPT # Interacts with OpenAI ChatGPT
pip install speechbrain

@ -0,0 +1,17 @@
import pyttsx3
engine = pyttsx3.init()
voices = engine.getProperty('voices')
# engine.setProperty('voice', voices[3].id)
# engine.say("I will speak this text")
# engine.runAndWait()
# engine = pyttsx3.init()
# voices = engine.getProperty('voices')
# print(voices)
for voice in voices:
engine.setProperty('voice', voice.id)
print(voice)
engine.say('The quick brown fox jumped over the lazy dog.')
engine.runAndWait()

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>test</title>
</head>
<body>
<script type="text/javascript" src="https://files.coinmarketcap.com/static/widget/coinPriceBlock.js"></script>
<div id="coinmarketcap-widget-coin-price-block" coins="1,1027,1839,52,3890" currency="USD" theme="light" transparent="false" show-symbol-logo="true"></div>
</body>
</html>

@ -0,0 +1 @@
/Users/sam/.cache/huggingface/hub/models--speechbrain--tts-tacotron2-ljspeech/snapshots/f0c9855a337493070f576ef94dacd0ed407e04f2/hyperparams.yaml

@ -0,0 +1 @@
/Users/sam/.cache/huggingface/hub/models--speechbrain--tts-tacotron2-ljspeech/snapshots/f0c9855a337493070f576ef94dacd0ed407e04f2/model.ckpt

@ -0,0 +1 @@
/Users/sam/.cache/huggingface/hub/models--speechbrain--tts-hifigan-ljspeech/snapshots/e0cc1f9be5b65d4612013f26867ca600e98bc1b6/generator.ckpt

@ -0,0 +1 @@
/Users/sam/.cache/huggingface/hub/models--speechbrain--tts-hifigan-ljspeech/snapshots/e0cc1f9be5b65d4612013f26867ca600e98bc1b6/hyperparams.yaml

@ -0,0 +1,20 @@
import torchaudio
from speechbrain.pretrained import Tacotron2
from speechbrain.pretrained import HIFIGAN
import sounddevice as sd
# Intialize TTS (tacotron2) and Vocoder (HiFIGAN)
tacotron2 = Tacotron2.from_hparams(source="speechbrain/tts-tacotron2-ljspeech", savedir="tmpdir_tts")
hifi_gan = HIFIGAN.from_hparams(source="speechbrain/tts-hifigan-ljspeech", savedir="tmpdir_vocoder")
# Running the TTS
mel_output, mel_length, alignment = tacotron2.encode_text("This is an open-source toolkit for the development of speech technologies.")
# Running Vocoder (spectrogram-to-waveform)
waveforms = hifi_gan.decode_batch(mel_output)
print(waveforms)
#Audio(waveforms.detach().cpu().squeeze(), rate=22050)
# sd.play(waveforms, 22050)
torchaudio.io.play_audio(waveform=waveforms, sample_rate=22050)
# torchaudio.Audio(waveforms.detach().cpu().squeeze(), rate=22050)

@ -0,0 +1,28 @@
print("Processing...")
text = r.recognize_whisper(audio, language="english")
print(f"Whisper thinks you said {text}")
#TODO: Check for Apollo
def callback(recognizer, audio):
try:
pass
except sr.UnknownValueError:
print("Whisper could not understand audio")
except sr.RequestError as e:
print("Could not request results from Whisper")
r = sr.Recognizer()
m = sr.Microphone()
with m as source:
r.adjust_for_ambient_noise(source) # we only need to calibrate once, before we start listening
stop_listening = r.listen_in_background(m, callback)
print("Listening...")
while True:
time.sleep(0.1) # we're not listening anymore,
# print('1')

@ -0,0 +1,39 @@
#!/usr/bin/env python3
import time
import speech_recognition as sr
# this is called from the background thread
def callback(recognizer, audio):
# received audio data, now we'll recognize it using Google Speech Recognition
try:
print("Processing...")
text = r.recognize_whisper(audio, language="english")
print(f"Whisper thinks you said {text}")
except sr.UnknownValueError:
print("Whisper could not understand audio")
except sr.RequestError as e:
print("Could not request results from Whisper")
r = sr.Recognizer()
m = sr.Microphone()
with m as source:
r.adjust_for_ambient_noise(source) # we only need to calibrate once, before we start listening
# start listening in the background (note that we don't have to do this inside a `with` statement)
stop_listening = r.listen_in_background(m, callback)
# `stop_listening` is now a function that, when called, stops background listening
# do some unrelated computations for 5 seconds
# for _ in range(50):
# time.sleep(0.1) # we're still listening even though the main thread is doing other things
# print('0')
# calling this function requests that the background listener stop listening
# stop_listening(wait_for_stop=False)
# do some more unrelated things
print("Listening...")
while True:
time.sleep(0.1) # we're not listening anymore,
# print('1')
Loading…
Cancel
Save