[Fix] Fixed TTS quoted mode Error
This commit is contained in:
@@ -12,7 +12,7 @@ export async function sayTTS(character:character,text:string) {
|
|||||||
|
|
||||||
if(character.ttsReadOnlyQuoted){
|
if(character.ttsReadOnlyQuoted){
|
||||||
const matches = text.match(/"(.*?)"/g)
|
const matches = text.match(/"(.*?)"/g)
|
||||||
if(matches.length > 0){
|
if(matches && matches.length > 0){
|
||||||
text = matches.map(match => match.slice(1, -1)).join("");
|
text = matches.map(match => match.slice(1, -1)).join("");
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
@@ -89,7 +89,7 @@ export async function sayTTS(character:character,text:string) {
|
|||||||
const audioBuffer = await audioContext.decodeAudioData(await getVoice.arrayBuffer())
|
const audioBuffer = await audioContext.decodeAudioData(await getVoice.arrayBuffer())
|
||||||
sourceNode = audioContext.createBufferSource();
|
sourceNode = audioContext.createBufferSource();
|
||||||
sourceNode.buffer = audioBuffer;
|
sourceNode.buffer = audioBuffer;
|
||||||
sourceNode.connect(audioContext.destination);
|
sourceNode.connect(audioContext.destination);
|
||||||
sourceNode.start();
|
sourceNode.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,8 +92,6 @@ async function jpTrans(text:string) {
|
|||||||
|
|
||||||
const url = `https://${host}/translate_a/single?client=gtx&sl=auto&tl=ja&dt=t&q=` + encodeURIComponent(text)
|
const url = `https://${host}/translate_a/single?client=gtx&sl=auto&tl=ja&dt=t&q=` + encodeURIComponent(text)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const f = await fetch(url, {
|
const f = await fetch(url, {
|
||||||
|
|
||||||
method: "GET",
|
method: "GET",
|
||||||
@@ -102,16 +100,17 @@ async function jpTrans(text:string) {
|
|||||||
|
|
||||||
const res = await f.json()
|
const res = await f.json()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(typeof(res) === 'string'){
|
if(typeof(res) === 'string'){
|
||||||
|
|
||||||
return res as unknown as string
|
return res as unknown as string
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const result = res[0].map((s) => s[0]).filter(Boolean).join('');
|
let result = ''
|
||||||
|
|
||||||
|
if (res[0]) {
|
||||||
|
result = res[0].map((s) => s[0]).filter(Boolean).join('');
|
||||||
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user