Spaces:
Build error
Build error
adds get duration endpoint
Browse files- app.py +20 -1
- requirements.txt +1 -0
app.py
CHANGED
@@ -1,10 +1,11 @@
|
|
1 |
-
from datetime import datetime, timedelta
|
2 |
import os
|
3 |
|
4 |
import gradio as gr
|
5 |
import torch
|
6 |
import nemo.collections.asr as nemo_asr
|
7 |
import wandb
|
|
|
|
|
8 |
|
9 |
MODEL_HISTORY_DAYS = 180
|
10 |
WANDB_ENTITY = os.environ.get("WANDB_ENTITY", "tarteel")
|
@@ -43,6 +44,12 @@ def transcribe(audio_file):
|
|
43 |
return transcription_file
|
44 |
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
demo = gr.Blocks()
|
47 |
|
48 |
with demo:
|
@@ -66,4 +73,16 @@ with demo:
|
|
66 |
api_name="transcribe",
|
67 |
)
|
68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
69 |
demo.launch()
|
|
|
|
|
1 |
import os
|
2 |
|
3 |
import gradio as gr
|
4 |
import torch
|
5 |
import nemo.collections.asr as nemo_asr
|
6 |
import wandb
|
7 |
+
from pydub.utils import mediainfo
|
8 |
+
|
9 |
|
10 |
MODEL_HISTORY_DAYS = 180
|
11 |
WANDB_ENTITY = os.environ.get("WANDB_ENTITY", "tarteel")
|
|
|
44 |
return transcription_file
|
45 |
|
46 |
|
47 |
+
def get_duration_ms(audio_file):
|
48 |
+
duration = mediainfo(audio_file)["duration"]
|
49 |
+
duration_ms = int(duration) * 1000
|
50 |
+
return duration_ms
|
51 |
+
|
52 |
+
|
53 |
demo = gr.Blocks()
|
54 |
|
55 |
with demo:
|
|
|
73 |
api_name="transcribe",
|
74 |
)
|
75 |
|
76 |
+
b2 = gr.Button("Get Duration")
|
77 |
+
|
78 |
+
with gr.Row():
|
79 |
+
duration = gr.TextArea(label="Duration")
|
80 |
+
|
81 |
+
b2.click(
|
82 |
+
get_duration_ms,
|
83 |
+
inputs=[audio_file],
|
84 |
+
outputs=[duration],
|
85 |
+
api_name="get_duration_ms",
|
86 |
+
)
|
87 |
+
|
88 |
demo.launch()
|
requirements.txt
CHANGED
@@ -2,3 +2,4 @@ torchaudio
|
|
2 |
nemo_toolkit[asr]==1.19.0
|
3 |
hydra-core
|
4 |
wandb
|
|
|
|
2 |
nemo_toolkit[asr]==1.19.0
|
3 |
hydra-core
|
4 |
wandb
|
5 |
+
pydub
|