@@ -35,6 +35,9 @@ export const useTtsStore = defineStore("ttsStore", {
3535 autoplay : store . get ( "autoplay" ) ,
3636 updateNotification : store . get ( "updateNotification" ) ,
3737 titleStyle : store . get ( "titleStyle" ) ,
38+ api : store . get ( "api" ) ,
39+ speechKey : store . get ( "speechKey" ) ,
40+ serviceRegion : store . get ( "serviceRegion" ) ,
3841 } ,
3942 isLoading : false ,
4043 currMp3Buffer : Buffer . alloc ( 0 ) ,
@@ -90,6 +93,12 @@ export const useTtsStore = defineStore("ttsStore", {
9093 setAutoPlay ( ) {
9194 store . set ( "autoplay" , this . config . autoplay ) ;
9295 } ,
96+ setSpeechKey ( ) {
97+ store . set ( "speechKey" , this . config . speechKey ) ;
98+ } ,
99+ setServiceRegion ( ) {
100+ store . set ( "serviceRegion" , this . config . serviceRegion ) ;
101+ } ,
93102 addFormConfig ( ) {
94103 this . config . formConfigJson [ this . currConfigName ] = this . formConfig ;
95104 this . genFormConfig ( ) ;
@@ -124,7 +133,7 @@ export const useTtsStore = defineStore("ttsStore", {
124133 ? this . inputs . inputValue
125134 : this . inputs . ssmlValue ,
126135 } ;
127- if ( this . page . tabIndex == "1" && this . formConfig . api && this . inputs . inputValue . length > 400 ) {
136+ if ( this . page . tabIndex == "1" && this . formConfig . api == 1 && this . inputs . inputValue . length > 400 ) {
128137 const delimiters = ",。?,.?" . split ( "" ) ;
129138 const maxSize = 300 ;
130139 ipcRenderer . send ( "log.info" , "字数过多,正在对文本切片。。。" ) ;
@@ -165,7 +174,9 @@ export const useTtsStore = defineStore("ttsStore", {
165174 this . formConfig . role ,
166175 ( this . formConfig . speed - 1 ) * 100 ,
167176 ( this . formConfig . pitch - 1 ) * 50 ,
168- this . formConfig . api
177+ this . formConfig . api ,
178+ this . config . speechKey ,
179+ this . config . serviceRegion
169180 ) ;
170181 this . currMp3Buffer = Buffer . concat ( [ this . currMp3Buffer , buffers ] ) ;
171182 ipcRenderer . send (
@@ -206,7 +217,9 @@ export const useTtsStore = defineStore("ttsStore", {
206217 this . formConfig . role ,
207218 ( this . formConfig . speed - 1 ) * 100 ,
208219 ( this . formConfig . pitch - 1 ) * 50 ,
209- this . formConfig . api
220+ this . formConfig . api ,
221+ this . config . speechKey ,
222+ this . config . serviceRegion
210223 )
211224 . then ( ( mp3buffer : any ) => {
212225 this . currMp3Buffer = mp3buffer ;
@@ -261,7 +274,7 @@ export const useTtsStore = defineStore("ttsStore", {
261274 inps . inputValue = datastr ;
262275 let buffer = Buffer . alloc ( 0 ) ;
263276
264- if ( datastr . length > 400 && this . formConfig . api ) {
277+ if ( datastr . length > 400 && this . formConfig . api == 1 ) {
265278 const delimiters = ",。?,.? " . split ( "" ) ;
266279 const maxSize = 300 ;
267280 ipcRenderer . send ( "log.info" , "字数过多,正在对文本切片。。。" ) ;
@@ -302,7 +315,9 @@ export const useTtsStore = defineStore("ttsStore", {
302315 this . formConfig . role ,
303316 ( this . formConfig . speed - 1 ) * 100 ,
304317 ( this . formConfig . pitch - 1 ) * 50 ,
305- this . formConfig . api
318+ this . formConfig . api ,
319+ this . config . speechKey ,
320+ this . config . serviceRegion
306321 ) ;
307322 buffer = Buffer . concat ( [ buffer , buffers ] ) ;
308323 ipcRenderer . send (
@@ -347,7 +362,9 @@ export const useTtsStore = defineStore("ttsStore", {
347362 this . formConfig . role ,
348363 ( this . formConfig . speed - 1 ) * 100 ,
349364 ( this . formConfig . pitch - 1 ) * 50 ,
350- this . formConfig . api
365+ this . formConfig . api ,
366+ this . config . speechKey ,
367+ this . config . serviceRegion
351368 )
352369 . then ( ( mp3buffer : any ) => {
353370 fs . writeFileSync ( filePath , mp3buffer ) ;
@@ -410,7 +427,9 @@ export const useTtsStore = defineStore("ttsStore", {
410427 this . formConfig . role ,
411428 ( this . formConfig . speed - 1 ) * 100 ,
412429 ( this . formConfig . pitch - 1 ) * 50 ,
413- this . formConfig . api
430+ this . formConfig . api ,
431+ this . config . speechKey ,
432+ this . config . serviceRegion
414433 )
415434 . then ( ( mp3buffer : any ) => {
416435 this . currMp3Buffer = mp3buffer ;
0 commit comments