Saiyaswanth007 commited on
Commit
f66d06e
·
1 Parent(s): da90629

Check point 4

Browse files
Files changed (1) hide show
  1. app.py +15 -2
app.py CHANGED
@@ -16,6 +16,7 @@ import asyncio
16
  import uvicorn
17
  from queue import Queue
18
  import logging
 
19
 
20
  # Set up logging
21
  logging.basicConfig(level=logging.INFO)
@@ -419,7 +420,7 @@ class RealtimeSpeakerDiarization:
419
  # Setup recorder configuration
420
  recorder_config = {
421
  'spinner': False,
422
- 'use_microphone': True, # Changed to True for direct microphone input
423
  'model': FINAL_TRANSCRIPTION_MODEL,
424
  'language': TRANSCRIPTION_LANGUAGE,
425
  'silero_sensitivity': SILERO_SENSITIVITY,
@@ -650,7 +651,9 @@ def start_recording():
650
  """Start recording and transcription"""
651
  try:
652
  result = diarization_system.start_recording()
653
- return f"🎙️ {result}"
 
 
654
  except Exception as e:
655
  return f"❌ Failed to start recording: {str(e)}"
656
 
@@ -700,6 +703,14 @@ def create_interface():
700
 
701
  with gr.Row():
702
  with gr.Column(scale=2):
 
 
 
 
 
 
 
 
703
  # Conversation display
704
  conversation_output = gr.HTML(
705
  value="<div style='padding: 20px; background: #f8f9fa; border-radius: 10px; min-height: 300px;'><i>Click 'Initialize System' to start...</i></div>",
@@ -773,6 +784,8 @@ def create_interface():
773
 
774
  def on_start():
775
  result = start_recording()
 
 
776
  return result, gr.update(interactive=False), gr.update(interactive=True)
777
 
778
  def on_stop():
 
16
  import uvicorn
17
  from queue import Queue
18
  import logging
19
+ from gradio_webrtc import WebRTC
20
 
21
  # Set up logging
22
  logging.basicConfig(level=logging.INFO)
 
420
  # Setup recorder configuration
421
  recorder_config = {
422
  'spinner': False,
423
+ 'use_microphone': False, # Change to False for Hugging Face Spaces
424
  'model': FINAL_TRANSCRIPTION_MODEL,
425
  'language': TRANSCRIPTION_LANGUAGE,
426
  'silero_sensitivity': SILERO_SENSITIVITY,
 
651
  """Start recording and transcription"""
652
  try:
653
  result = diarization_system.start_recording()
654
+ # Connect WebRTC to server stream
655
+ audio_webrtc.stream_url = "/stream" # This is your FastRTC endpoint
656
+ return result
657
  except Exception as e:
658
  return f"❌ Failed to start recording: {str(e)}"
659
 
 
703
 
704
  with gr.Row():
705
  with gr.Column(scale=2):
706
+ # Add WebRTC component for audio streaming
707
+ audio_webrtc = WebRTC(
708
+ label="Audio Input",
709
+ sources=["microphone"],
710
+ streaming=True,
711
+ rtc_configuration={"iceServers": [{"urls": ["stun:stun.l.google.com:19302"]}]}
712
+ )
713
+
714
  # Conversation display
715
  conversation_output = gr.HTML(
716
  value="<div style='padding: 20px; background: #f8f9fa; border-radius: 10px; min-height: 300px;'><i>Click 'Initialize System' to start...</i></div>",
 
784
 
785
  def on_start():
786
  result = start_recording()
787
+ # Connect WebRTC to server stream
788
+ audio_webrtc.stream_url = "/stream" # This is your FastRTC endpoint
789
  return result, gr.update(interactive=False), gr.update(interactive=True)
790
 
791
  def on_stop():