Skip to content

Commit

Permalink
adding readme and requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
gkamradt committed Feb 28, 2024
1 parent 78c39de commit 6599f98
Show file tree
Hide file tree
Showing 6 changed files with 109 additions and 14 deletions.
12 changes: 6 additions & 6 deletions QuickAgent.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import requests
import time
import os
from time import sleep

from langchain_core.prompts import ChatPromptTemplate
from langchain_groq import ChatGroq
Expand Down Expand Up @@ -71,7 +70,7 @@ def process(self, text):
class TextToSpeech:
# Set your Deepgram API Key and desired voice model
DG_API_KEY = os.getenv("DEEPGRAM_API_KEY")
MODEL_NAME = "alpha-helios-en" # Example model name, change as needed
MODEL_NAME = "alpha-asteria-en" # Example model name, change as needed

@staticmethod
def is_installed(lib_name: str) -> bool:
Expand Down Expand Up @@ -133,7 +132,6 @@ def get_full_transcript(self):
transcript_collector = TranscriptCollector()

async def get_transcript(callback):
transcript_ready = asyncio.Event() # Create an asyncio Event to wait on
transcription_complete = asyncio.Event() # Event to signal transcription completion

try:
Expand All @@ -142,6 +140,7 @@ async def get_transcript(callback):
deepgram: DeepgramClient = DeepgramClient("", config)

dg_connection = deepgram.listen.asynclive.v("1")
print ("Listening...")

async def on_message(self, result, **kwargs):
sentence = result.channel.alternatives[0].transcript
Expand Down Expand Up @@ -169,7 +168,8 @@ async def on_message(self, result, **kwargs):
encoding="linear16",
channels=1,
sample_rate=16000,
endpointing=True
endpointing=300,
smart_format=True,
)

await dg_connection.start(options)
Expand Down Expand Up @@ -200,10 +200,10 @@ def handle_full_sentence(full_sentence):
self.transcription_response = full_sentence

# Loop indefinitely until "goodbye" is detected
while "goodbye" not in self.transcription_response.lower():
while True:
await get_transcript(handle_full_sentence)

# Check if "goodbye" was said to exit the loop
# Check for "goodbye" to exit the loop
if "goodbye" in self.transcription_response.lower():
break

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Quick Voice bot demo

This is a alpha demo showing a bot that uses Text-To-Speech, Speech-To-Text, and a language model to have a conversation with a user.

This demo is set up to use [Deepgram](www.deepgram.com) for the audio service and [Groq](https://groq.com/) the LLM.

This demo utilizes streaming to speed things up
7 changes: 4 additions & 3 deletions building_blocks/llm.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from langchain_core.prompts import ChatPromptTemplate
from langchain_groq import ChatGroq
from dotenv import load_dotenv

import os

load_dotenv()

def batch():
chat = ChatGroq(temperature=0, model_name="mixtral-8x7b-32768", groq_api_key=os.getenv("GROQ_API_KEY"))

Expand All @@ -22,5 +23,5 @@ def streaming():
for chunk in chain.stream({"topic": "The Moon"}):
print(chunk.content, end="", flush=True)

batch()
# streaming()
# batch()
streaming()
2 changes: 1 addition & 1 deletion building_blocks/text_to_speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def send_tts_request(text):
print(f"Time to First Byte (TTFB): {ttfb}ms")
# Write each chunk to the player's stdin immediately
player_process.stdin.write(chunk) # type: ignore
player_process.stdin.flush() # type: ignore
player_process.stdin.flush() # type: ignore

# Close the player's stdin and wait for the process to finish
if player_process.stdin:
Expand Down
88 changes: 88 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
aiohttp==3.9.3
aiosignal==1.3.1
annotated-types==0.6.0
anyio==4.3.0
appnope==0.1.4
asttokens==2.4.1
asyncio==3.4.3
attrs==23.2.0
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
comm==0.2.1
dataclasses-json==0.6.4
debugpy==1.8.1
decorator==5.1.1
deepgram-sdk==3.1.4
distro==1.9.0
executing==2.0.1
frozenlist==1.4.1
gevent==24.2.1
greenlet==3.0.3
groq==0.4.1
h11==0.14.0
httpcore==1.0.4
httpx==0.27.0
idna==3.6
ipykernel==6.29.2
ipython==8.22.1
jedi==0.19.1
jsonpatch==1.33
jsonpointer==2.4
jupyter_client==8.6.0
jupyter_core==5.7.1
langchain==0.1.9
langchain-community==0.0.24
langchain-core==0.1.26
langchain-groq==0.0.1
langchain-openai==0.0.7
langsmith==0.1.6
marshmallow==3.20.2
matplotlib-inline==0.1.6
multidict==6.0.5
mypy-extensions==1.0.0
nest-asyncio==1.6.0
numpy==1.26.4
openai==1.12.0
orjson==3.9.15
packaging==23.2
parso==0.8.3
pexpect==4.9.0
platformdirs==4.2.0
prompt-toolkit==3.0.43
psutil==5.9.8
ptyprocess==0.7.0
pure-eval==0.2.2
PyAudio==0.2.14
pycparser==2.21
pydantic==2.6.2
pydantic_core==2.16.3
pygame==2.5.2
Pygments==2.17.2
python-dateutil==2.8.2
python-dotenv==1.0.1
PyYAML==6.0.1
pyzmq==25.1.2
regex==2023.12.25
requests==2.31.0
six==1.16.0
sniffio==1.3.0
sounddevice==0.4.6
SQLAlchemy==2.0.27
stack-data==0.6.3
tenacity==8.2.3
tiktoken==0.6.0
tornado==6.4
tqdm==4.66.2
traitlets==5.14.1
typing-inspect==0.9.0
typing_extensions==4.9.0
urllib3==2.2.1
verboselogs==1.7
wcwidth==0.2.13
websocket==0.2.1
websocket-client==1.7.0
websockets==12.0
yarl==1.9.4
zope.event==5.0
zope.interface==6.2
7 changes: 3 additions & 4 deletions system_prompt.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
You are a conversational assistant named Dan.
You are a conversational assistant named Eliza.
Use short, conversational responses as if you're having a live conversation.
Do not give any extra context about yourself.
Your response should be 10 words max.
Don't punctuation, speak without it.
Your response should be under 20 words.
Do not respond with any code, only conversation

0 comments on commit 6599f98

Please sign in to comment.