Open asciiman opened 2 years ago
The code documentation mentioned:
const audioConfigOutput = AudioConfig.fromSpeakerOutput(player);
is only for browsers.
I am using expo-av to play audio buffer.
` async function playAudioFromArrayBuffer(arrayBuffer: ArrayBuffer) { const audio = new Audio.Sound()
try {
// Convert the ArrayBuffer to a base64-encoded string
const base64Data = await arrayBufferToBase64(arrayBuffer)
// Load the audio from the base64 string
await audio.loadAsync({ uri: `data:audio/wav;base64,${base64Data}` })
// Play the loaded audio
await audio.playAsync()
} catch (error) {
console.error("Error playing audio:", error)
}
} `
// const speechConfig = SpeechConfig.fromSubscription("avhvhjdhajhajahajaahaj", "eastus");
// let audioContext = new AudioContext();
// let bufferSource = audioContext.createBufferSource();
const speechConfig = sdk.SpeechConfig.fromSubscription("------------------", "eastus");
const audioConfig = sdk.AudioConfig.fromDefaultSpeakerOutput();
let synthesizer = new sdk.SpeechSynthesizer(speechConfig, audioConfig);
let text = 'Hello how are you young man';
synthesizer.speakTextAsync(text, result => {
console.log(result.audioData);
return result.audioData
}, error => {
console.log({error});
});
i am using this code on react native my result,audio data is empty array and i didn't hear any voice any help ?
Hello,
I am trying to get SpeechSynthesizer working in React Native. I set up code as outlined in this example. It looks like the audio is running. I get the
+++ onAudioEnd
console log after a moment. However, I hear no sound. I tried this on the simulator and a real device and of course made sure that the volume was turned up.This code was pasted inside the existing
startRecognition()
function in place of the existing code in that function.Any ideas?