from utils.translate import *
# translating is optional
def translate_text(text):
global is_Speaking
# subtitle will act as subtitle for the viewer
# subtitle = translate_google(text, "ID")
# tts will be the string to be converted to audio
detect = detect_google(text)
# tts = translate_google(text, f"{detect}", "JA")
tts = translate_google(text, f"{detect}", "JA")
# tts_en = translate_google(text, f"{detect}", "EN")
# tts_es = translate_google(text, f"{detect}", "ES")
try:
# print("ID Answer: " + subtitle)
print("JP Answer: " + tts)
# print("EN Answer: " + tts_en)
# print("ES Answer: " + tts_es)
except:
print("Error translating text")
return
This is from another AI Waifu code. You use your voice to talk with the AI and then translate the response from OpenAI API to Katakana (Japanese) to Voicevox (text-to-speech)
I think we can use a simple function like this: