Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,5 @@
|
|
1 |
import io
|
2 |
-
import re
|
3 |
-
import gradio as gr
|
4 |
import torch
|
5 |
from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
6 |
import requests
|
@@ -13,6 +12,10 @@ from pydub import AudioSegment
|
|
13 |
import librosa
|
14 |
import numpy as np
|
15 |
from pyannote.audio import Pipeline
|
|
|
|
|
|
|
|
|
16 |
|
17 |
# Initialize the speaker diarization pipeline
|
18 |
try:
|
@@ -165,16 +168,19 @@ def download_transcript(transcript):
|
|
165 |
temp_file_path = temp_file.name
|
166 |
return temp_file_path
|
167 |
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
video_url
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
|
|
|
|
|
|
|
1 |
import io
|
2 |
+
import re
|
|
|
3 |
import torch
|
4 |
from transformers import WhisperProcessor, WhisperForConditionalGeneration
|
5 |
import requests
|
|
|
12 |
import librosa
|
13 |
import numpy as np
|
14 |
from pyannote.audio import Pipeline
|
15 |
+
from pywebio import start_server, config, session
|
16 |
+
from pywebio.input import input, input_group
|
17 |
+
from pywebio.output import put_text, put_markdown, put_file
|
18 |
+
from pywebio.session import run_js
|
19 |
|
20 |
# Initialize the speaker diarization pipeline
|
21 |
try:
|
|
|
168 |
temp_file_path = temp_file.name
|
169 |
return temp_file_path
|
170 |
|
171 |
+
def pdf_compressor():
|
172 |
+
put_markdown("# Video Transcription")
|
173 |
+
video_url = input(label="Video URL")
|
174 |
+
if video_url:
|
175 |
+
put_text("Transcribing video...")
|
176 |
+
transcript = transcribe_video(video_url)
|
177 |
+
if transcript:
|
178 |
+
put_text(transcript)
|
179 |
+
download_link = download_transcript(transcript)
|
180 |
+
put_file(download_link, label="Download Transcript")
|
181 |
+
else:
|
182 |
+
put_text("Failed to transcribe video.")
|
183 |
+
|
184 |
+
if __name__ == '__main__':
|
185 |
+
config(title="Video Transcription", description="Transcribe audio from a video URL using Whisper and PyAnnote")
|
186 |
+
start_server(pdf_compressor, host='0.0.0.0', port=7860, debug=True, enable_rate_limit=True, max_payload_size='200M')
|