sohojoe commited on
Commit
31bfb8d
1 Parent(s): ac171cf

added debug time to show the time multiple of actual audio time to streaming time

Browse files
Files changed (1) hide show
  1. debug.py +36 -0
debug.py CHANGED
@@ -7,6 +7,41 @@ from concurrent.futures import ThreadPoolExecutor
7
  from audio_stream_processor import AudioStreamProcessor
8
  from streaming_chat_service import StreamingChatService
9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
  def test_sentance_lenghts():
12
  load_dotenv()
@@ -92,5 +127,6 @@ def run_debug_code():
92
 
93
 
94
  if __name__ == '__main__':
 
95
  # test_sentance_lenghts()
96
  run_debug_code()
 
7
  from audio_stream_processor import AudioStreamProcessor
8
  from streaming_chat_service import StreamingChatService
9
 
10
+ def time_sentance_lenghts():
11
+ load_dotenv()
12
+
13
+ print ("Initializing Chat")
14
+ # audio_processor = AudioStreamProcessor()
15
+ user_speech_service0 = SpeechService(voice_id="Adam")
16
+ prompts = [
17
+ "hello, i am a long sentance, how are you today? Tell me about your shadow self?",
18
+ "a shorter sentance",
19
+ "Jung believed that the process of self-discovery and personal growth involves confronting and integrating the shadow self into the conscious mind.",
20
+ "By doing so, we become more self-aware and more fully actualized individuals.",
21
+ ]
22
+
23
+ print ("Timing prompts\n")
24
+ for prompt in prompts:
25
+ start_time = time.time()
26
+ start_stream_time = time.time()
27
+ stream = user_speech_service0.stream(prompt)
28
+ audio = b""
29
+ for chunk in stream:
30
+ if chunk is not None:
31
+ audio += chunk
32
+ end_stream_time = time.time()
33
+ from elevenlabs import play
34
+ start_speech_time = time.time()
35
+ play(audio)
36
+ end_speech_time = time.time()
37
+ end_time = time.time()
38
+ total_time = (end_time - start_time)
39
+ stream_time = (end_stream_time - start_stream_time)
40
+ speech_time = (end_speech_time - start_speech_time)
41
+ stream_multiple = speech_time / stream_time
42
+ print(f"Stream time: {stream_time:.4f}, Acutual audio time: {speech_time:.4f}, a multiple of {stream_multiple:.2f}. for prompt: {prompt}")
43
+
44
+ print ("\nChat success")
45
 
46
  def test_sentance_lenghts():
47
  load_dotenv()
 
127
 
128
 
129
  if __name__ == '__main__':
130
+ # time_sentance_lenghts()
131
  # test_sentance_lenghts()
132
  run_debug_code()