@@ -5,7 +5,7 @@ import { type SsmlOptions, genSSML } from './genSSML';
55const API =
66 'https://southeastasia.api.speech.microsoft.com/accfreetrial/texttospeech/acc/v3.0-beta1/vcg/speak' ;
77
8- export const postMicrosoftSpeech = ( text : string , options : SsmlOptions ) : [ any , any ] => {
8+ export const fetchMicrosoftSpeech = async ( text : string , options : SsmlOptions ) => {
99 const data = JSON . stringify ( {
1010 offsetInPlainText : 0 ,
1111 properties : {
@@ -15,7 +15,7 @@ export const postMicrosoftSpeech = (text: string, options: SsmlOptions): [any, a
1515 ttsAudioFormat : 'audio-24khz-160kbitrate-mono-mp3' ,
1616 } ) ;
1717
18- const DEFAULT_HEADERS = {
18+ const DEFAULT_HEADERS = new Headers ( {
1919 'accept' : '*/*' ,
2020 'accept-language' : 'zh-CN,zh;q=0.9' ,
2121 'authority' : 'southeastasia.api.speech.microsoft.com' ,
@@ -30,15 +30,13 @@ export const postMicrosoftSpeech = (text: string, options: SsmlOptions): [any, a
3030 'sec-fetch-site' : 'same-site' ,
3131 'user-agent' :
3232 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36' ,
33- } ;
33+ } ) ;
3434
35- return [
36- API ,
37- {
38- body : data ,
39- headers : DEFAULT_HEADERS ,
40- method : 'POST' ,
41- responseType : 'arraybuffer' ,
42- } ,
43- ] ;
35+ return await fetch ( API , {
36+ body : data ,
37+ headers : DEFAULT_HEADERS ,
38+ method : 'POST' ,
39+ // @ts -ignore
40+ responseType : 'arraybuffer' ,
41+ } ) ;
4442} ;
0 commit comments