Spaces:
Running
on
T4
Running
on
T4
v2 added
Browse files- app/__pycache__/matcher.cpython-310.pyc +0 -0
- app/__pycache__/passing.cpython-310.pyc +0 -0
- app/__pycache__/transcriber.cpython-310.pyc +0 -0
- app/matcher.py +2 -2
- app/passing.py +5 -5
- app/routers/V1/voice/__pycache__/voice_router.cpython-310.pyc +0 -0
- app/routers/V1/voice/voice_router.py +1 -4
- app/transcriber.py +2 -1
app/__pycache__/matcher.cpython-310.pyc
CHANGED
Binary files a/app/__pycache__/matcher.cpython-310.pyc and b/app/__pycache__/matcher.cpython-310.pyc differ
|
|
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/matcher.py
CHANGED
@@ -19,6 +19,6 @@ def sequence_match(a, b):
|
|
19 |
|
20 |
|
21 |
def match(original, transcription):
|
22 |
-
sequence = sequence_match(original, transcription)
|
23 |
-
phonetic = phonetic_match(original, transcription)
|
24 |
return sequence, phonetic
|
|
|
19 |
|
20 |
|
21 |
def match(original, transcription):
|
22 |
+
sequence = sequence_match(original.lower(), transcription.lower())
|
23 |
+
phonetic = phonetic_match(original.lower(), transcription.lower())
|
24 |
return sequence, phonetic
|
app/passing.py
CHANGED
@@ -5,7 +5,7 @@ def normalize_euclidean(euclidean, max_value):
|
|
5 |
"""
|
6 |
return max(0, 100 - (euclidean / max_value) * 100)
|
7 |
|
8 |
-
def calculate_passing(sequence, phonetic, cosine, euclidean, passing_threshold=
|
9 |
# Normalize sequence and phonetic to 0-100 scale
|
10 |
sequence_normalized = sequence * 100
|
11 |
phonetic_normalized = phonetic * 100
|
@@ -17,10 +17,10 @@ def calculate_passing(sequence, phonetic, cosine, euclidean, passing_threshold=6
|
|
17 |
|
18 |
# Calculate the weighted average
|
19 |
weights = {
|
20 |
-
'sequence': 0.
|
21 |
-
'phonetic': 0.
|
22 |
-
'cosine': 0
|
23 |
-
'euclidean': 0
|
24 |
}
|
25 |
|
26 |
weighted_score = (
|
|
|
5 |
"""
|
6 |
return max(0, 100 - (euclidean / max_value) * 100)
|
7 |
|
8 |
+
def calculate_passing(sequence, phonetic, cosine=0, euclidean=0, passing_threshold=50, euclidean_max=200):
|
9 |
# Normalize sequence and phonetic to 0-100 scale
|
10 |
sequence_normalized = sequence * 100
|
11 |
phonetic_normalized = phonetic * 100
|
|
|
17 |
|
18 |
# Calculate the weighted average
|
19 |
weights = {
|
20 |
+
'sequence': 0.50,
|
21 |
+
'phonetic': 0.50,
|
22 |
+
'cosine': 0,
|
23 |
+
'euclidean': 0
|
24 |
}
|
25 |
|
26 |
weighted_score = (
|
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
@@ -55,10 +55,7 @@ async def transcribe_audio(
|
|
55 |
text = get_transcription(filename_recorded)
|
56 |
text = clean_transcription(text)
|
57 |
sequence, phonetic = match(matcher_text, text)
|
58 |
-
|
59 |
-
filename_original, filename_recorded
|
60 |
-
)
|
61 |
-
weighted_score, is_passing = calculate_passing(sequence, phonetic, Cosine, Euclidean)
|
62 |
return JSONResponse(
|
63 |
{
|
64 |
"transcription": text,
|
|
|
55 |
text = get_transcription(filename_recorded)
|
56 |
text = clean_transcription(text)
|
57 |
sequence, phonetic = match(matcher_text, text)
|
58 |
+
weighted_score, is_passing = calculate_passing(sequence, phonetic)
|
|
|
|
|
|
|
59 |
return JSONResponse(
|
60 |
{
|
61 |
"transcription": text,
|
app/transcriber.py
CHANGED
@@ -6,7 +6,8 @@ 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 = "
|
|
|
10 |
|
11 |
model = AutoModelForSpeechSeq2Seq.from_pretrained(
|
12 |
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 |
|
12 |
model = AutoModelForSpeechSeq2Seq.from_pretrained(
|
13 |
model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True, use_safetensors=True
|