kadirnar commited on
Commit
4f9e791
·
1 Parent(s): f9ee273

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -70
app.py CHANGED
@@ -1,7 +1,6 @@
1
  import gradio as gr
2
 
3
  from whisperplus.pipelines.whisper import SpeechToTextPipeline
4
- from whisperplus.pipelines.whisper_diarize import ASRDiarizationPipeline
5
  from whisperplus.utils.download_utils import download_and_convert_to_mp3
6
  from whisperplus.utils.text_utils import format_speech_to_dialogue
7
 
@@ -27,35 +26,6 @@ def youtube_url_to_text(url, model_id, language_choice):
27
  return transcript, video_path
28
 
29
 
30
- def speaker_diarization(url, model_id):
31
- """
32
- Main function that downloads and converts a video to MP3 format, performs speech-to-text conversion using
33
- a specified model, and returns the transcript along with the video path.
34
-
35
- Args:
36
- url (str): The URL of the video to download and convert.
37
- model_id (str): The ID of the speech-to-text model to use.
38
- language_choice (str): The language choice for the speech-to-text conversion.
39
-
40
- Returns:
41
- transcript (str): The transcript of the speech-to-text conversion.
42
- video_path (str): The path of the downloaded video.
43
- """
44
-
45
- pipeline = ASRDiarizationPipeline.from_pretrained(
46
- asr_model=model_id,
47
- diarizer_model="pyannote/speaker-diarization",
48
- use_auth_token="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",
49
- chunk_length_s=30,
50
- device="cuda",
51
- )
52
-
53
- audio_path = download_and_convert_to_mp3(url)
54
- output_text = pipeline(audio_path)
55
- dialogue = format_speech_to_dialogue(output_text)
56
- return dialogue, audio_path
57
-
58
-
59
  def youtube_url_to_text_app():
60
  with gr.Blocks():
61
  with gr.Row():
@@ -104,44 +74,6 @@ def youtube_url_to_text_app():
104
  )
105
 
106
 
107
- def speaker_diarization_app():
108
- with gr.Blocks():
109
- with gr.Row():
110
- with gr.Column():
111
- youtube_url_path = gr.Text(placeholder="Enter Youtube URL", label="Youtube URL")
112
-
113
- whisper_model_id = gr.Dropdown(
114
- choices=[
115
- "openai/whisper-large-v3",
116
- "openai/whisper-large",
117
- "openai/whisper-medium",
118
- "openai/whisper-base",
119
- "openai/whisper-small",
120
- "openai/whisper-tiny",
121
- ],
122
- value="openai/whisper-large-v3",
123
- label="Whisper Model",
124
- )
125
-
126
- num_speakers = gr.Number(value=2, label="Number of Speakers")
127
- min_speaker = gr.Number(value=1, label="Minimum Number of Speakers")
128
- max_speaker = gr.Number(value=2, label="Maximum Number of Speakers")
129
- whisperplus_in_predict = gr.Button(value="Generator")
130
-
131
- with gr.Column():
132
- output_text = gr.Textbox(label="Output Text")
133
- output_audio = gr.Audio(label="Output Audio")
134
-
135
- whisperplus_in_predict.click(
136
- fn=speaker_diarization,
137
- inputs=[
138
- youtube_url_path,
139
- whisper_model_id,
140
- ],
141
- outputs=[output_text, output_audio],
142
- )
143
-
144
-
145
  gradio_app = gr.Blocks()
146
  with gradio_app:
147
  gr.HTML(
@@ -161,8 +93,6 @@ with gradio_app:
161
  with gr.Column():
162
  with gr.Tab(label="Youtube URL to Text"):
163
  youtube_url_to_text_app()
164
- with gr.Tab(label="Speaker Diarization"):
165
- speaker_diarization_app()
166
 
167
  gradio_app.queue()
168
  gradio_app.launch(debug=True)
 
1
  import gradio as gr
2
 
3
  from whisperplus.pipelines.whisper import SpeechToTextPipeline
 
4
  from whisperplus.utils.download_utils import download_and_convert_to_mp3
5
  from whisperplus.utils.text_utils import format_speech_to_dialogue
6
 
 
26
  return transcript, video_path
27
 
28
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  def youtube_url_to_text_app():
30
  with gr.Blocks():
31
  with gr.Row():
 
74
  )
75
 
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  gradio_app = gr.Blocks()
78
  with gradio_app:
79
  gr.HTML(
 
93
  with gr.Column():
94
  with gr.Tab(label="Youtube URL to Text"):
95
  youtube_url_to_text_app()
 
 
96
 
97
  gradio_app.queue()
98
  gradio_app.launch(debug=True)