Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -63,7 +63,8 @@ def transcribe(audio, task_type):
|
|
63 |
waveform, sample_rate = resample_audio(audio)
|
64 |
|
65 |
# Use the pipeline to perform transcription
|
66 |
-
|
|
|
67 |
|
68 |
return text
|
69 |
|
@@ -80,7 +81,9 @@ def get_wav_files(directory):
|
|
80 |
# List all files in the directory
|
81 |
files = os.listdir(directory)
|
82 |
# Filter for .wav files and create absolute paths
|
83 |
-
wav_files = [
|
|
|
|
|
84 |
return wav_files
|
85 |
|
86 |
def main():
|
@@ -91,7 +94,7 @@ def main():
|
|
91 |
iface = gr.Interface(
|
92 |
fn=transcribe,
|
93 |
inputs=[
|
94 |
-
gr.Audio(type="filepath", value=example_files[0]),
|
95 |
gr.Radio(choices=["transcribe", "translate"], label="Task Type", value="transcribe")
|
96 |
],
|
97 |
outputs="text",
|
|
|
63 |
waveform, sample_rate = resample_audio(audio)
|
64 |
|
65 |
# Use the pipeline to perform transcription
|
66 |
+
sample = {"array": waveform.squeeze().numpy(), "sampling_rate": sample_rate}
|
67 |
+
text = pipe(sample, generate_kwargs={"task": task_type, "language": language})["text"]
|
68 |
|
69 |
return text
|
70 |
|
|
|
81 |
# List all files in the directory
|
82 |
files = os.listdir(directory)
|
83 |
# Filter for .wav files and create absolute paths
|
84 |
+
wav_files = [os.path.abspath(os.path.join(directory, file)) for file in files if file.endswith('.wav')]
|
85 |
+
wav_files = [[f, "transcribe"] for f in wav_files]
|
86 |
+
|
87 |
return wav_files
|
88 |
|
89 |
def main():
|
|
|
94 |
iface = gr.Interface(
|
95 |
fn=transcribe,
|
96 |
inputs=[
|
97 |
+
gr.Audio(type="filepath", value=example_files[0][0]),
|
98 |
gr.Radio(choices=["transcribe", "translate"], label="Task Type", value="transcribe")
|
99 |
],
|
100 |
outputs="text",
|