Delik commited on
Commit
8289149
1 Parent(s): 76efec6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -9
app.py CHANGED
@@ -4,30 +4,28 @@ import torch
4
  import io
5
  from pyannote.audio import Pipeline
6
  from pyannote.audio import Audio
7
- from pyannote.audio.pipelines.utils.hook import TimingHook
8
  from pyannote.core import Segment
9
 
10
  pipeline = Pipeline.from_pretrained(
11
  "pyannote/speaker-diarization-3.1",
12
  use_auth_token=os.environ['api'])
13
 
14
- def process_audio(audio_file):
15
  # Save the uploaded audio file to a temporary location
16
- temp_file = "temp_audio.wav"
17
- with open(temp_file, "wb") as f:
18
- f.write(audio_file.read())
19
 
20
- # Use the diarization pipeline to process the audio file
21
- diarization = pipeline(temp_file)
22
 
23
  # Remove the temporary file
24
- os.remove(temp_file)
25
 
26
  # Return the diarization output
27
  return diarization
28
 
29
  with gr.Blocks() as demo:
30
- audio_input = gr.File(label="Upload Audio", file_types=["audio"])
31
  process_button = gr.Button("Process")
32
  diarization_output = gr.JSON(label="Diarization Output")
33
 
 
4
  import io
5
  from pyannote.audio import Pipeline
6
  from pyannote.audio import Audio
 
7
  from pyannote.core import Segment
8
 
9
  pipeline = Pipeline.from_pretrained(
10
  "pyannote/speaker-diarization-3.1",
11
  use_auth_token=os.environ['api'])
12
 
13
+ def process_audio(audio):
14
  # Save the uploaded audio file to a temporary location
15
+ with open("temp.wav", "wb") as f:
16
+ f.write(audio)
 
17
 
18
+ # Use the diarization pipeline to process the audio
19
+ diarization = pipeline("temp.wav")
20
 
21
  # Remove the temporary file
22
+ os.remove("temp.wav")
23
 
24
  # Return the diarization output
25
  return diarization
26
 
27
  with gr.Blocks() as demo:
28
+ audio_input = gr.Audio(label="Upload Audio")
29
  process_button = gr.Button("Process")
30
  diarization_output = gr.JSON(label="Diarization Output")
31