Pragnakal commited on
Commit
d4ae66d
·
verified ·
1 Parent(s): 2dc62dd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -16
app.py CHANGED
@@ -1,4 +1,5 @@
1
  import gradio as gr
 
2
  from pyannote.audio import Pipeline
3
  from pyannote.core import Segment
4
  from pyannote.audio import Audio
@@ -12,24 +13,10 @@ pipeline = Pipeline.from_pretrained("pyannote/speaker-diarization-3.1",use_auth_
12
  def respond(audio_input):
13
  # Save the audio input to a file
14
  audio_file = audio_input
15
- audio_input.save(audio_file)
16
-
17
  # Perform diarization on the whole file
18
  diarization = pipeline(audio_file)
19
 
20
- # Example: Extract and process a specific segment
21
- excerpt = Segment(start=2.0, end=5.0)
22
- waveform, sample_rate = Audio().crop(audio_file, excerpt)
23
-
24
- # Further processing (placeholder for actual implementation)
25
- text_response = f"Processed segment from {excerpt.start} to {excerpt.end} seconds."
26
- output_path = "response.wav" # Placeholder path
27
-
28
- # Generate an audio file as the response (placeholder for TTS implementation)
29
- audio = AudioSegment.from_wav(output_path)
30
- duration = len(audio) / 1000
31
-
32
- return text_response, output_path
33
 
34
  input_audio = gr.Audio(
35
  sources=["microphone"],
@@ -44,7 +31,7 @@ input_audio = gr.Audio(
44
  gr.Interface(
45
  fn=respond,
46
  inputs=input_audio,
47
- outputs=["text", "audio"],
48
  title="Tommy Vercetti Chatbot",
49
  description="Chat with Tommy Vercetti from GTA Vice City. Get responses in both text and voice!"
50
  ).launch(debug=True)
 
1
  import gradio as gr
2
+ import os
3
  from pyannote.audio import Pipeline
4
  from pyannote.core import Segment
5
  from pyannote.audio import Audio
 
13
  def respond(audio_input):
14
  # Save the audio input to a file
15
  audio_file = audio_input
 
 
16
  # Perform diarization on the whole file
17
  diarization = pipeline(audio_file)
18
 
19
+ return text_response
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  input_audio = gr.Audio(
22
  sources=["microphone"],
 
31
  gr.Interface(
32
  fn=respond,
33
  inputs=input_audio,
34
+ outputs="text",
35
  title="Tommy Vercetti Chatbot",
36
  description="Chat with Tommy Vercetti from GTA Vice City. Get responses in both text and voice!"
37
  ).launch(debug=True)