Request to google speech to text api returns no result, but ok status 200 and totalBilledTime and requestId. I sent a request via postman but doesn’t work either.
payload and code
{
"audio": {
"content": "IyFBTVItV0IKPBEGMCKqipOg06tQh7T39t4hHZjS5QoilnoJgtNEVyLJBCCACUHaCAvK5OYQvK2AIsCZcnmtz8qjOmA8QEAAu7bsoGE/KwPbgoVVJS+CQIglsNaM3UX/nYwncqVl0AqYx7STeSW73SahbWYiIaWuYgxm1MhaMDxgQjB3edzCICteSSRYdJfBFxc+UeCw5FklJqLXpxTlqa4gNB3OTZPI8UPNJGFqVu5QPHIxgGb72rxzeWqYRzda/dzIR5Fl0DZhTnfHt45kk3xTDLzeC89oSGNOsEk/NUWBD1Qiqg6uGSrghrA8ajGAqvvqtNI5aoqGlu489mLebqnM0vqPYxaBNHhh98IJVW68vlvNiBIG8u8ND5Qr4YRr1xKgLlWXWDxKcYCq9+pacViNdIPjl/nbsMzrKyrT07OReP8/hPvhDjYFs/nQzIpC9QqE603gDlbdgirkynkm4bKgPGoxgKrz6vb0Me+axjdzt/ZNOyPfjQ4Ut9NMFWN885RHhvUJ5PE1q+DEJp1a74h81sfQYCTt+/Cz/dg8bDGAmf/mlPM5KYjHFtW3SAIZdAXy4PoeyvFT/7bUsSjc4EbuGjVydgEsiLmFnmGAKvAkScZB6NMLoDxUcYBV+9Y4U1li3oQyU3ucYosBM7+ty6WaXH74a7nreRZMjXmRMu8/PjAfZtHHA1LOfaLNzuiTKo9g"
},
"config": {
"encoding": "AMR_WB",
"sampleRateHertz": 16000,
"languageCode": "en-US"
}
}
code:
import { Audio } from "expo-av";
import { MutableRefObject } from "react";
import * as FileSystem from "expo-file-system";
import { Platform } from "react-native";
import * as Device from "expo-device";
import { readBlobAsBase64 } from "./readBlobAsBase64";
export const transcribeSpeech = async (
audioRecordingRef: MutableRefObject<Audio.Recording>
) => {
try {
await Audio.setAudioModeAsync({
allowsRecordingIOS: false,
playsInSilentModeIOS: false,
});
const isPrepared = audioRecordingRef?.current?._canRecord;
if (isPrepared) {
await audioRecordingRef?.current?.stopAndUnloadAsync();
const recordingUri = audioRecordingRef?.current?.getURI() || "";
let base64Uri = "";
if (Platform.OS === "web") {
const blob = await fetch(recordingUri).then((res) => res.blob());
const foundBase64 = (await readBlobAsBase64(blob)) as string;
// Example: data:audio/wav;base64,asdjfioasjdfoaipsjdf
const removedPrefixBase64 = foundBase64.split("base64,")[1];
base64Uri = removedPrefixBase64;
} else {
base64Uri = await FileSystem.readAsStringAsync(recordingUri, {
encoding: FileSystem.EncodingType.Base64,
});
}
const dataUrl = base64Uri;