Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -41,27 +41,30 @@ def _return_yt_html_embed(yt_url):
|
|
41 |
# Transcription function (Fix applied)
|
42 |
def transcribe(audio_file, task):
|
43 |
if audio_file is None:
|
44 |
-
raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting
|
45 |
|
46 |
-
#
|
47 |
-
|
|
|
48 |
|
49 |
-
#
|
|
|
|
|
|
|
50 |
inputs = {
|
51 |
-
"raw": np.array(audio_array),
|
52 |
"sampling_rate": pipe.feature_extractor.sampling_rate
|
53 |
}
|
54 |
|
55 |
# Perform transcription
|
56 |
result = pipe(
|
57 |
-
inputs,
|
58 |
-
batch_size=BATCH_SIZE,
|
59 |
-
generate_kwargs={"task": task},
|
60 |
return_timestamps=True
|
61 |
)
|
62 |
|
63 |
return result["text"]
|
64 |
-
|
65 |
# Download YouTube audio
|
66 |
def download_yt_audio(yt_url, filename):
|
67 |
ydl_opts = {
|
|
|
41 |
# Transcription function (Fix applied)
|
42 |
def transcribe(audio_file, task):
|
43 |
if audio_file is None:
|
44 |
+
raise gr.Error("No audio file submitted! Please upload or record an audio file before submitting.")
|
45 |
|
46 |
+
# Open file as binary to ensure correct data type
|
47 |
+
with open(audio_file, "rb") as f:
|
48 |
+
audio_data = f.read()
|
49 |
|
50 |
+
# Read audio using ffmpeg_read (correcting input format)
|
51 |
+
audio_array = ffmpeg_read(audio_data, pipe.feature_extractor.sampling_rate)
|
52 |
+
|
53 |
+
# Convert to proper format
|
54 |
inputs = {
|
55 |
+
"raw": np.array(audio_array),
|
56 |
"sampling_rate": pipe.feature_extractor.sampling_rate
|
57 |
}
|
58 |
|
59 |
# Perform transcription
|
60 |
result = pipe(
|
61 |
+
inputs,
|
62 |
+
batch_size=BATCH_SIZE,
|
63 |
+
generate_kwargs={"task": task},
|
64 |
return_timestamps=True
|
65 |
)
|
66 |
|
67 |
return result["text"]
|
|
|
68 |
# Download YouTube audio
|
69 |
def download_yt_audio(yt_url, filename):
|
70 |
ydl_opts = {
|