project_charles / debug.py
sohojoe's picture
add some debug code that suggest that we are still been buffered somehow
ac171cf
raw
history blame
3.29 kB
import time
from clip_transform import CLIPTransform
from chat_service import ChatService
from dotenv import load_dotenv
from speech_service import SpeechService
from concurrent.futures import ThreadPoolExecutor
from audio_stream_processor import AudioStreamProcessor
from streaming_chat_service import StreamingChatService
def test_sentance_lenghts():
load_dotenv()
print ("Initializing Chat")
audio_processor = AudioStreamProcessor()
user_speech_service0 = SpeechService(voice_id="Adam")
user_speech_service1 = SpeechService(voice_id="Adam")
user_speech_service2 = SpeechService(voice_id="Adam")
user_speech_service3 = SpeechService(voice_id="Adam")
prompts = [
"hello, i am a long sentance, how are you today? Tell me about your shadow self?",
"a shorter sentance",
"Jung believed that the process of self-discovery and personal growth involves confronting and integrating the shadow self into the conscious mind.",
"By doing so, we become more self-aware and more fully actualized individuals.",
]
first = True
stream1 = user_speech_service1.stream(prompts[1])
stream0 = user_speech_service0.stream(prompts[0])
time.sleep(5)
stream2 = user_speech_service2.stream(prompts[2])
stream3 = user_speech_service3.stream(prompts[3])
audio_processor.add_audio_stream(stream0)
audio_processor.add_audio_stream(stream1)
audio_processor.add_audio_stream(stream2)
audio_processor.add_audio_stream(stream3)
audio_processor.close()
from elevenlabs import generate, play
speech0 = generate(prompts[0], voice="Adam")
speech1 = generate(prompts[1], voice="Adam")
speech2 = generate(prompts[2], voice="Adam")
speech3 = generate(prompts[3], voice="Adam")
play(speech0)
play(speech1)
play(speech2)
play(speech1)
play(speech3)
play(speech1)
# for prompt in prompts:
# stream = user_speech_service.stream(prompt)
# if first:
# first = False
# time.sleep(5)
# audio_processor.add_audio_stream(stream)
audio_processor.close()
print ("Chat success")
def run_debug_code():
load_dotenv()
# print ("Initializing CLIP templates")
# clip_transform = CLIPTransform()
# print ("CLIP success")
print ("Initializing Chat")
# chat_service = ChatService()
audio_processor = AudioStreamProcessor()
chat_service = StreamingChatService(audio_processor, voice_id="2OviOUQc1JsQRQgNkVBj") # Chales003
user_speech_service = SpeechService(voice_id="Adam")
# user_speech_service.print_voices() # if you want to see your custom voices
prompts = [
"hello, how are you today?",
"tell me about your shadow self?",
"hmm, interesting, tell me more about that.",
"wait, that is so interesting, what else?",
]
for prompt in prompts:
print ("")
print (f'prompt: "{prompt}"')
stream = user_speech_service.stream(prompt)
audio_processor.add_audio_stream(stream)
print ("")
print (f'response:')
response = chat_service.respond_to(prompt)
audio_processor.close()
print ("Chat success")
if __name__ == '__main__':
# test_sentance_lenghts()
run_debug_code()