Spaces:
Running
Running
Commit
·
f1e695a
1
Parent(s):
33e4e84
Update voice files id handler FastAPI
Browse files- .gitignore +1 -0
- app.py +2 -2
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
.env
|
app.py
CHANGED
@@ -132,8 +132,8 @@ async def voice_transcribe(file: UploadFile = File(...)): # noqa: B008
|
|
132 |
# ── 1. Transcribe
|
133 |
speech, sample_rate = sf.read(tmp_path)
|
134 |
inputs = processor(speech, sampling_rate=sample_rate, return_tensors="pt")
|
135 |
-
|
136 |
-
generated_ids = model.generate(
|
137 |
question = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
|
138 |
if not question:
|
139 |
raise ValueError("Empty transcription")
|
|
|
132 |
# ── 1. Transcribe
|
133 |
speech, sample_rate = sf.read(tmp_path)
|
134 |
inputs = processor(speech, sampling_rate=sample_rate, return_tensors="pt")
|
135 |
+
input_features = inputs["input_features"].to("cpu")
|
136 |
+
generated_ids = model.generate(input_features)
|
137 |
question = processor.batch_decode(generated_ids, skip_special_tokens=True)[0].strip()
|
138 |
if not question:
|
139 |
raise ValueError("Empty transcription")
|