Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
ZennyKenny
commited on
implement output
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
import torch
|
3 |
from transformers import pipeline
|
4 |
import librosa
|
|
|
5 |
import spaces
|
6 |
|
7 |
def split_audio(audio_path, chunk_duration=30):
|
@@ -17,9 +18,9 @@ def transcribe_long_audio(audio_path, transcriber, chunk_duration=30):
|
|
17 |
"""Transcribe long audio by splitting into smaller chunks."""
|
18 |
chunks, sr = split_audio(audio_path, chunk_duration)
|
19 |
transcriptions = []
|
20 |
-
for chunk in chunks:
|
21 |
-
temp_path = "
|
22 |
-
|
23 |
transcription = transcriber(temp_path)["text"]
|
24 |
transcriptions.append(transcription)
|
25 |
return " ".join(transcriptions)
|
|
|
2 |
import torch
|
3 |
from transformers import pipeline
|
4 |
import librosa
|
5 |
+
import soundfile as sf
|
6 |
import spaces
|
7 |
|
8 |
def split_audio(audio_path, chunk_duration=30):
|
|
|
18 |
"""Transcribe long audio by splitting into smaller chunks."""
|
19 |
chunks, sr = split_audio(audio_path, chunk_duration)
|
20 |
transcriptions = []
|
21 |
+
for i, chunk in enumerate(chunks):
|
22 |
+
temp_path = f"temp_chunk_{i}.wav"
|
23 |
+
sf.write(temp_path, chunk, sr) # Save the chunk using soundfile
|
24 |
transcription = transcriber(temp_path)["text"]
|
25 |
transcriptions.append(transcription)
|
26 |
return " ".join(transcriptions)
|