29
29
@click ="
30
30
() => {
31
31
bus.emit('play:pause', props.data.record_id)
32
- audioManage?.play(props.data.answer_text, true)
32
+ audioManage?.play(props.data.answer_text, true, true )
33
33
}
34
34
"
35
35
>
@@ -261,12 +261,14 @@ class AudioManage {
261
261
textList: Array <string >
262
262
statusList: Array <AudioStatus >
263
263
audioList: Array <HTMLAudioElement | SpeechSynthesisUtterance >
264
+ tryList: Array <number >
264
265
ttsType: string
265
266
root: Element
266
267
constructor (ttsType : string , root : HTMLDivElement ) {
267
268
this .textList = []
268
269
this .audioList = []
269
270
this .statusList = []
271
+ this .tryList = []
270
272
this .ttsType = ttsType
271
273
this .root = root
272
274
}
@@ -279,6 +281,7 @@ class AudioManage {
279
281
newTextList .forEach ((text , index ) => {
280
282
this .textList .push (text )
281
283
this .statusList .push (AudioStatus .MOUNTED )
284
+ this .tryList .push (1 )
282
285
index = this .textList .length - 1
283
286
if (this .ttsType === ' TTS' ) {
284
287
const audioElement: HTMLAudioElement = document .createElement (' audio' )
@@ -363,10 +366,12 @@ class AudioManage {
363
366
}
364
367
reTryError() {
365
368
this .statusList .forEach ((status , index ) => {
366
- if (status === AudioStatus .ERROR ) {
369
+ if (status === AudioStatus .ERROR && this .tryList [index ] <= 3 ) {
370
+ this .tryList [index ]++
367
371
const audioElement = this .audioList [index ]
368
372
if (audioElement instanceof HTMLAudioElement ) {
369
373
const text = this .textList [index ]
374
+ this .statusList [index ] = AudioStatus .MOUNTED
370
375
applicationApi
371
376
.postTextToSpeech (
372
377
(props .applicationId as string ) || (id as string ),
@@ -401,7 +406,10 @@ class AudioManage {
401
406
isPlaying() {
402
407
return this .statusList .some ((item ) => [AudioStatus .PLAY_INT ].includes (item ))
403
408
}
404
- play(text ? : string , is_end ? : boolean ) {
409
+ play(text ? : string , is_end ? : boolean , self ? : boolean ) {
410
+ if (self ) {
411
+ this .tryList = this .tryList .map ((item ) => 0 )
412
+ }
405
413
if (text ) {
406
414
const textList = this .getTextList (text , is_end ? true : false )
407
415
this .appendTextList (textList )
0 commit comments