Spaces:
Sleeping
Sleeping
remove convert to audio
Browse files- routers/get_transcript.py +10 -8
routers/get_transcript.py
CHANGED
@@ -28,27 +28,29 @@ def get_transcript(audio_path: str, model_size: str = "distil-large-v3", api_key
|
|
28 |
|
29 |
output_audio_folder = f"./cached/audio"
|
30 |
|
31 |
-
if not os.path.exists(output_audio_folder):
|
32 |
-
|
33 |
|
34 |
-
output_file = f"{output_audio_folder}/{audio_path.split('/')[-1].split(".")[0]}.mp3"
|
35 |
|
36 |
st = time.time()
|
37 |
|
38 |
-
convert_to_audio(audio_path.strip(), output_file)
|
39 |
|
40 |
try:
|
41 |
model_run = WhisperModel(model_size, device="cpu", compute_type="int8")
|
42 |
segments, info = model_run.transcribe(
|
43 |
-
|
44 |
beam_size=16,
|
45 |
language="en",
|
46 |
condition_on_previous_text=False,
|
47 |
)
|
48 |
-
|
|
|
|
|
49 |
except Exception as error:
|
50 |
-
if os.path.exists(output_file):
|
51 |
-
|
52 |
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=f"error>>>: {error}")
|
53 |
|
54 |
text = ""
|
|
|
28 |
|
29 |
output_audio_folder = f"./cached/audio"
|
30 |
|
31 |
+
# if not os.path.exists(output_audio_folder):
|
32 |
+
# os.makedirs(output_audio_folder)
|
33 |
|
34 |
+
# output_file = f"{output_audio_folder}/{audio_path.split('/')[-1].split(".")[0]}.mp3"
|
35 |
|
36 |
st = time.time()
|
37 |
|
38 |
+
# convert_to_audio(audio_path.strip(), output_file)
|
39 |
|
40 |
try:
|
41 |
model_run = WhisperModel(model_size, device="cpu", compute_type="int8")
|
42 |
segments, info = model_run.transcribe(
|
43 |
+
audio_path,
|
44 |
beam_size=16,
|
45 |
language="en",
|
46 |
condition_on_previous_text=False,
|
47 |
)
|
48 |
+
|
49 |
+
# if os.path.exists(output_file):
|
50 |
+
# os.remove(output_file)
|
51 |
except Exception as error:
|
52 |
+
# if os.path.exists(output_file):
|
53 |
+
# os.remove(output_file)
|
54 |
raise HTTPException(status_code=status.HTTP_403_FORBIDDEN, detail=f"error>>>: {error}")
|
55 |
|
56 |
text = ""
|