You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
850B

  1. from bot import bot_factory
  2. from common.singleton import singleton
  3. from voice import voice_factory
  4. @singleton
  5. class Bridge(object):
  6. def __init__(self):
  7. self.bots = {
  8. "chat": bot_factory.create_bot("chatGPT"),
  9. "voice_to_text": voice_factory.create_voice("openai"),
  10. # "text_to_voice": voice_factory.create_voice("baidu")
  11. }
  12. try:
  13. self.bots["text_to_voice"] = voice_factory.create_voice("baidu")
  14. except ModuleNotFoundError as e:
  15. print(e)
  16. def fetch_reply_content(self, query, context):
  17. return self.bots["chat"].reply(query, context)
  18. def fetch_voice_to_text(self, voiceFile):
  19. return self.bots["voice_to_text"].voiceToText(voiceFile)
  20. def fetch_text_to_voice(self, text):
  21. return self.bots["text_to_voice"].textToVoice(text)