added VOICEVOX TTS
This commit is contained in:
@@ -70,4 +70,45 @@ async function googleTrans(text:string, reverse:boolean) {
|
||||
|
||||
return result
|
||||
|
||||
}
|
||||
|
||||
export async function translateVox(text:string) {
|
||||
const plug = await translatorPlugin(text, 'en', 'jp')
|
||||
if(plug){
|
||||
return plug.content
|
||||
}
|
||||
|
||||
return jpTrans(text)
|
||||
}
|
||||
|
||||
|
||||
async function jpTrans(text:string) {
|
||||
|
||||
const host = 'translate.googleapis.com'
|
||||
|
||||
|
||||
const url = `https://${host}/translate_a/single?client=gtx&sl=auto&tl=ja&dt=t&q=` + encodeURIComponent(text)
|
||||
|
||||
|
||||
|
||||
const f = await fetch(url, {
|
||||
|
||||
method: "GET",
|
||||
|
||||
})
|
||||
|
||||
const res = await f.json()
|
||||
|
||||
|
||||
|
||||
if(typeof(res) === 'string'){
|
||||
|
||||
return res as unknown as string
|
||||
|
||||
}
|
||||
|
||||
const result = res[0].map((s) => s[0]).filter(Boolean).join('');
|
||||
|
||||
return result
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user