fix language issue
Browse files- app.py +11 -11
- transcribe.py +1 -1
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from fastapi import FastAPI, UploadFile, File, Form, HTTPException
|
2 |
from fastapi.responses import JSONResponse
|
3 |
from fastapi.middleware.cors import CORSMiddleware
|
4 |
import sys
|
@@ -32,7 +32,7 @@ app.add_middleware(
|
|
32 |
@app.post("/analyze_fluency/")
|
33 |
async def analyze_fluency(file: UploadFile):
|
34 |
# idk if we can use pydantic model here If we need I can add later
|
35 |
-
if not file.filename.endswith(('.wav', '.mp3')):
|
36 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
37 |
|
38 |
# Generate a safe temporary file path for temporary storage of the uploaded file this will be deleted after processing
|
@@ -64,7 +64,7 @@ async def analyze_tone(file: UploadFile):
|
|
64 |
"""
|
65 |
Endpoint to analyze tone of an uploaded audio file (.wav or .mp3).
|
66 |
"""
|
67 |
-
if not file.filename.endswith(('.wav', '.mp3')):
|
68 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
69 |
|
70 |
# Generate a safe temporary file path
|
@@ -96,7 +96,7 @@ async def analyze_vcs(file: UploadFile):
|
|
96 |
"""
|
97 |
Endpoint to analyze voice clarity of an uploaded audio file (.wav or .mp3).
|
98 |
"""
|
99 |
-
if not file.filename.endswith(('.wav', '.mp3')):
|
100 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
101 |
|
102 |
# Generate a safe temporary file path
|
@@ -128,7 +128,7 @@ async def analyze_vers(file: UploadFile):
|
|
128 |
"""
|
129 |
Endpoint to analyze VERS of an uploaded audio file (.wav or .mp3).
|
130 |
"""
|
131 |
-
if not file.filename.endswith(('.wav', '.mp3')):
|
132 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
133 |
|
134 |
# Generate a safe temporary file path
|
@@ -160,7 +160,7 @@ async def analyze_voice_confidence(file: UploadFile):
|
|
160 |
"""
|
161 |
Endpoint to analyze voice confidence of an uploaded audio file (.wav or .mp3).
|
162 |
"""
|
163 |
-
if not file.filename.endswith(('.wav', '.mp3')):
|
164 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
165 |
|
166 |
# Generate a safe temporary file path
|
@@ -192,7 +192,7 @@ async def analyze_vps(file: UploadFile):
|
|
192 |
"""
|
193 |
Endpoint to analyze voice pacing score of an uploaded audio file (.wav or .mp3).
|
194 |
"""
|
195 |
-
if not file.filename.endswith(('.wav', '.mp3')):
|
196 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
197 |
|
198 |
# Generate a safe temporary file path
|
@@ -224,7 +224,7 @@ async def analyze_voice_engagement_score(file: UploadFile):
|
|
224 |
"""
|
225 |
Endpoint to analyze voice engagement score of an uploaded audio file (.wav or .mp3).
|
226 |
"""
|
227 |
-
if not file.filename.endswith(('.wav', '.mp3')):
|
228 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
229 |
|
230 |
# Generate a safe temporary file path
|
@@ -256,7 +256,7 @@ async def analyze_fillers_count(file: UploadFile):
|
|
256 |
"""
|
257 |
Endpoint to analyze filler words in an uploaded audio file (.wav or .mp3).
|
258 |
"""
|
259 |
-
if not file.filename.endswith(('.wav', '.mp3','.mp4')):
|
260 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
261 |
|
262 |
# Generate a safe temporary file path
|
@@ -295,7 +295,7 @@ async def transcribe(file: UploadFile, language: str = Form(...)):
|
|
295 |
"""
|
296 |
#calculate time to transcribe
|
297 |
start_time = time.time()
|
298 |
-
if not file.filename.endswith(('.wav', '.mp3','mp4')):
|
299 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav ,mp4 and .mp3 files are supported.")
|
300 |
|
301 |
# Generate a safe temporary file path
|
@@ -334,7 +334,7 @@ async def analyze_all(file: UploadFile, language: str = Form(...)):
|
|
334 |
"""
|
335 |
Endpoint to analyze all aspects of an uploaded audio file (.wav or .mp3).
|
336 |
"""
|
337 |
-
if not file.filename.endswith(('.wav', '.mp3')):
|
338 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
339 |
|
340 |
# Generate a safe temporary file path
|
|
|
1 |
+
from fastapi import FastAPI, UploadFile, File, Form , HTTPException
|
2 |
from fastapi.responses import JSONResponse
|
3 |
from fastapi.middleware.cors import CORSMiddleware
|
4 |
import sys
|
|
|
32 |
@app.post("/analyze_fluency/")
|
33 |
async def analyze_fluency(file: UploadFile):
|
34 |
# idk if we can use pydantic model here If we need I can add later
|
35 |
+
if not file.filename.endswith(('.wav', '.mp3','.m4a','.mp4','.flac')):
|
36 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
37 |
|
38 |
# Generate a safe temporary file path for temporary storage of the uploaded file this will be deleted after processing
|
|
|
64 |
"""
|
65 |
Endpoint to analyze tone of an uploaded audio file (.wav or .mp3).
|
66 |
"""
|
67 |
+
if not file.filename.endswith(('.wav', '.mp3','.m4a','.mp4','.flac')):
|
68 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
69 |
|
70 |
# Generate a safe temporary file path
|
|
|
96 |
"""
|
97 |
Endpoint to analyze voice clarity of an uploaded audio file (.wav or .mp3).
|
98 |
"""
|
99 |
+
if not file.filename.endswith(('.wav', '.mp3','.m4a','.mp4','.flac')):
|
100 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
101 |
|
102 |
# Generate a safe temporary file path
|
|
|
128 |
"""
|
129 |
Endpoint to analyze VERS of an uploaded audio file (.wav or .mp3).
|
130 |
"""
|
131 |
+
if not file.filename.endswith(('.wav', '.mp3','.m4a','.mp4','.flac')):
|
132 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
133 |
|
134 |
# Generate a safe temporary file path
|
|
|
160 |
"""
|
161 |
Endpoint to analyze voice confidence of an uploaded audio file (.wav or .mp3).
|
162 |
"""
|
163 |
+
if not file.filename.endswith(('.wav', '.mp3','.m4a','.mp4','.flac')):
|
164 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
165 |
|
166 |
# Generate a safe temporary file path
|
|
|
192 |
"""
|
193 |
Endpoint to analyze voice pacing score of an uploaded audio file (.wav or .mp3).
|
194 |
"""
|
195 |
+
if not file.filename.endswith(('.wav', '.mp3','.m4a','.mp4','.flac')):
|
196 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
197 |
|
198 |
# Generate a safe temporary file path
|
|
|
224 |
"""
|
225 |
Endpoint to analyze voice engagement score of an uploaded audio file (.wav or .mp3).
|
226 |
"""
|
227 |
+
if not file.filename.endswith(('.wav', '.mp3','.m4a','.mp4','.flac')):
|
228 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
229 |
|
230 |
# Generate a safe temporary file path
|
|
|
256 |
"""
|
257 |
Endpoint to analyze filler words in an uploaded audio file (.wav or .mp3).
|
258 |
"""
|
259 |
+
if not file.filename.endswith(('.wav', '.mp3','.mp4','.m4a','.flac')):
|
260 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
261 |
|
262 |
# Generate a safe temporary file path
|
|
|
295 |
"""
|
296 |
#calculate time to transcribe
|
297 |
start_time = time.time()
|
298 |
+
if not file.filename.endswith(('.wav', '.mp3','mp4','.m4a','.flac')):
|
299 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav ,mp4 and .mp3 files are supported.")
|
300 |
|
301 |
# Generate a safe temporary file path
|
|
|
334 |
"""
|
335 |
Endpoint to analyze all aspects of an uploaded audio file (.wav or .mp3).
|
336 |
"""
|
337 |
+
if not file.filename.endswith(('.wav', '.mp3','.m4a','.mp4','.flac')):
|
338 |
raise HTTPException(status_code=400, detail="Invalid file type. Only .wav and .mp3 files are supported.")
|
339 |
|
340 |
# Generate a safe temporary file path
|
transcribe.py
CHANGED
@@ -8,7 +8,7 @@ def transcribe_audio(file_path: str, language, model_size=None) -> str:
|
|
8 |
print(f"Transcribing audio file: {file_path} with language: {language}")
|
9 |
# Configure for Hindi language
|
10 |
config = aai.TranscriptionConfig(
|
11 |
-
speech_model=aai.SpeechModel.
|
12 |
language_code=language
|
13 |
)
|
14 |
|
|
|
8 |
print(f"Transcribing audio file: {file_path} with language: {language}")
|
9 |
# Configure for Hindi language
|
10 |
config = aai.TranscriptionConfig(
|
11 |
+
speech_model=aai.SpeechModel.nano,
|
12 |
language_code=language
|
13 |
)
|
14 |
|