ishaq101 commited on
Commit
3f6c44e
·
1 Parent(s): 0d9931e

update sound

Browse files
Files changed (1) hide show
  1. src/services/voiceApi.ts +5 -0
src/services/voiceApi.ts CHANGED
@@ -40,6 +40,11 @@ export async function speechToText(
40
  form.append("provider", provider);
41
  const res = await fetch(`${VOICE_BASE_URL}/stt`, { method: "POST", body: form });
42
  if (!res.ok) throw new Error(`STT error: ${res.status}`);
 
 
 
 
 
43
  return res.json();
44
  }
45
 
 
40
  form.append("provider", provider);
41
  const res = await fetch(`${VOICE_BASE_URL}/stt`, { method: "POST", body: form });
42
  if (!res.ok) throw new Error(`STT error: ${res.status}`);
43
+ const contentType = res.headers.get("content-type") ?? "";
44
+ if (!contentType.includes("application/json")) {
45
+ const body = await res.text();
46
+ throw new Error(`STT returned non-JSON (${res.status}): ${body.slice(0, 200)}`);
47
+ }
48
  return res.json();
49
  }
50