Spaces:
Running
on
Zero
Running
on
Zero
rev app
Browse files
app.py
CHANGED
@@ -8,7 +8,7 @@ model = pipeline(
|
|
8 |
"automatic-speech-recognition",
|
9 |
model="Aekanun/whisper-small-hi",
|
10 |
device="cpu",
|
11 |
-
torch_dtype=torch.float16
|
12 |
)
|
13 |
|
14 |
@spaces.GPU
|
@@ -19,11 +19,15 @@ def transcribe_speech(audio):
|
|
19 |
return "กรุณาบันทึกเสียงก่อน"
|
20 |
|
21 |
# Move model to GPU with float16
|
22 |
-
model.model = model.model.to("cuda").half()
|
23 |
|
24 |
with torch.amp.autocast('cuda'):
|
25 |
-
# Process audio
|
26 |
-
result = model(
|
|
|
|
|
|
|
|
|
27 |
|
28 |
# Get text result
|
29 |
text = result["text"] if isinstance(result, dict) else result
|
|
|
8 |
"automatic-speech-recognition",
|
9 |
model="Aekanun/whisper-small-hi",
|
10 |
device="cpu",
|
11 |
+
torch_dtype=torch.float16
|
12 |
)
|
13 |
|
14 |
@spaces.GPU
|
|
|
19 |
return "กรุณาบันทึกเสียงก่อน"
|
20 |
|
21 |
# Move model to GPU with float16
|
22 |
+
model.model = model.model.to("cuda").half()
|
23 |
|
24 |
with torch.amp.autocast('cuda'):
|
25 |
+
# Process audio with chunk_length_s
|
26 |
+
result = model(
|
27 |
+
audio,
|
28 |
+
batch_size=1,
|
29 |
+
chunk_length_s=30 # แบ่งเสียงเป็นช่วงละ 30 วินาที
|
30 |
+
)
|
31 |
|
32 |
# Get text result
|
33 |
text = result["text"] if isinstance(result, dict) else result
|