【JavaScript】后端返回的二进制流音频数据或本地音频资源,前端如何播放?
一、接口设置
// 语音播放
export const getVoicePlay = (content: string) => {
return requestVoice({
url: '/tts/?text_prompt=' + content,
method: 'get',
responseType: 'blob', // 返回类型blob
});
};
二、数据处理播放
getVoicePlay(item.content).then((r