Spaces:
Running
on
T4
Running
on
T4
model updated
Browse files
app/__pycache__/passing.cpython-310.pyc
CHANGED
Binary files a/app/__pycache__/passing.cpython-310.pyc and b/app/__pycache__/passing.cpython-310.pyc differ
|
|
app/__pycache__/transcriber.cpython-310.pyc
CHANGED
Binary files a/app/__pycache__/transcriber.cpython-310.pyc and b/app/__pycache__/transcriber.cpython-310.pyc differ
|
|
app/routers/V1/voice/__pycache__/voice_router.cpython-310.pyc
CHANGED
Binary files a/app/routers/V1/voice/__pycache__/voice_router.cpython-310.pyc and b/app/routers/V1/voice/__pycache__/voice_router.cpython-310.pyc differ
|
|
app/routers/V1/voice/voice_router.py
CHANGED
@@ -23,25 +23,25 @@ async def transcribe_audio(
|
|
23 |
):
|
24 |
try:
|
25 |
# Validate URL
|
26 |
-
if not original_url.endswith(".wav"):
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
|
32 |
-
# Download the audio file from the URL
|
33 |
-
response = requests.get(original_url)
|
34 |
-
if response.status_code != 200:
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
filename_original = f"audio_{int(time.time())}_original.wav"
|
41 |
|
42 |
-
# Save the downloaded file temporarily
|
43 |
-
with open(filename_original, "wb") as buffer:
|
44 |
-
|
45 |
|
46 |
# Read file bytes
|
47 |
recorded_bytes = await recorded.read()
|
@@ -65,7 +65,7 @@ async def transcribe_audio(
|
|
65 |
)
|
66 |
finally:
|
67 |
# Clean up the temporary file
|
68 |
-
os.remove(filename_original)
|
69 |
os.remove(filename_recorded)
|
70 |
|
71 |
except Exception as e:
|
|
|
23 |
):
|
24 |
try:
|
25 |
# Validate URL
|
26 |
+
# if not original_url.endswith(".wav"):
|
27 |
+
# raise HTTPException(
|
28 |
+
# status_code=status.HTTP_400_BAD_REQUEST,
|
29 |
+
# detail="Invalid URL. Please provide a URL pointing to a wav file.",
|
30 |
+
# )
|
31 |
|
32 |
+
# # Download the audio file from the URL
|
33 |
+
# response = requests.get(original_url)
|
34 |
+
# if response.status_code != 200:
|
35 |
+
# raise HTTPException(
|
36 |
+
# status_code=status.HTTP_400_BAD_REQUEST,
|
37 |
+
# detail="Unable to download the audio file from the URL.",
|
38 |
+
# )
|
39 |
|
40 |
+
# filename_original = f"audio_{int(time.time())}_original.wav"
|
41 |
|
42 |
+
# # Save the downloaded file temporarily
|
43 |
+
# with open(filename_original, "wb") as buffer:
|
44 |
+
# buffer.write(response.content)
|
45 |
|
46 |
# Read file bytes
|
47 |
recorded_bytes = await recorded.read()
|
|
|
65 |
)
|
66 |
finally:
|
67 |
# Clean up the temporary file
|
68 |
+
# os.remove(filename_original)
|
69 |
os.remove(filename_recorded)
|
70 |
|
71 |
except Exception as e:
|
app/transcriber.py
CHANGED
@@ -6,8 +6,9 @@ from datasets import load_dataset
|
|
6 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
7 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
8 |
|
9 |
-
model_id = "openai/whisper-large-v3"
|
10 |
# model_id = "MothersTongue/mother_tongue_model"
|
|
|
11 |
|
12 |
model = AutoModelForSpeechSeq2Seq.from_pretrained(
|
13 |
model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
|
|
|
6 |
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
7 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
8 |
|
9 |
+
# model_id = "openai/whisper-large-v3"
|
10 |
# model_id = "MothersTongue/mother_tongue_model"
|
11 |
+
model_id = "MothersTongue/mother_tongue_model_v3"
|
12 |
|
13 |
model = AutoModelForSpeechSeq2Seq.from_pretrained(
|
14 |
model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
|