Update Voice_Assistant.py
Browse files- Voice_Assistant.py +5 -9
Voice_Assistant.py
CHANGED
|
@@ -1,7 +1,4 @@
|
|
| 1 |
import speech_recognition as sr
|
| 2 |
-
from transformers import pipeline
|
| 3 |
-
from transformers import Wav2Vec2Processor, Wav2Vec2ForCTC
|
| 4 |
-
|
| 5 |
from langchain.llms import HuggingFacePipeline
|
| 6 |
from langchain.chains import RetrievalQA
|
| 7 |
from langchain.embeddings import HuggingFaceEmbeddings
|
|
@@ -24,18 +21,17 @@ documents = loader.load()
|
|
| 24 |
# Open-source embedding model
|
| 25 |
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|
| 26 |
vectorstore = FAISS.from_documents(documents, embeddings)
|
| 27 |
-
|
| 28 |
-
# Ollama Model
|
| 29 |
ollama = Ollama(base_url='http://localhost:11434',model="llama3")
|
| 30 |
qa = RetrievalQA.from_chain_type(llm=ollama, chain_type="stuff", retriever=vectorstore.as_retriever())
|
| 31 |
|
| 32 |
# Speech recognition setup
|
| 33 |
r = sr.Recognizer()
|
| 34 |
-
|
| 35 |
-
# Initialize TTS with a model
|
| 36 |
tts = TTS(model_name="tts_models/en/ljspeech/glow-tts")
|
|
|
|
|
|
|
| 37 |
|
| 38 |
-
## Using Mozilla TTS (TTS)
|
| 39 |
def speak(text):
|
| 40 |
"""
|
| 41 |
Converts text to speech using Mozilla TTS, plays the audio, and then deletes the file.
|
|
@@ -95,4 +91,4 @@ def main():
|
|
| 95 |
|
| 96 |
|
| 97 |
if __name__ == "__main__":
|
| 98 |
-
main()
|
|
|
|
| 1 |
import speech_recognition as sr
|
|
|
|
|
|
|
|
|
|
| 2 |
from langchain.llms import HuggingFacePipeline
|
| 3 |
from langchain.chains import RetrievalQA
|
| 4 |
from langchain.embeddings import HuggingFaceEmbeddings
|
|
|
|
| 21 |
# Open-source embedding model
|
| 22 |
embeddings = HuggingFaceEmbeddings(model_name="sentence-transformers/all-MiniLM-L6-v2")
|
| 23 |
vectorstore = FAISS.from_documents(documents, embeddings)
|
| 24 |
+
|
|
|
|
| 25 |
ollama = Ollama(base_url='http://localhost:11434',model="llama3")
|
| 26 |
qa = RetrievalQA.from_chain_type(llm=ollama, chain_type="stuff", retriever=vectorstore.as_retriever())
|
| 27 |
|
| 28 |
# Speech recognition setup
|
| 29 |
r = sr.Recognizer()
|
| 30 |
+
|
|
|
|
| 31 |
tts = TTS(model_name="tts_models/en/ljspeech/glow-tts")
|
| 32 |
+
|
| 33 |
+
|
| 34 |
|
|
|
|
| 35 |
def speak(text):
|
| 36 |
"""
|
| 37 |
Converts text to speech using Mozilla TTS, plays the audio, and then deletes the file.
|
|
|
|
| 91 |
|
| 92 |
|
| 93 |
if __name__ == "__main__":
|
| 94 |
+
main()
|