Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

26 lines
565B

  1. """
  2. google voice service
  3. """
  4. import json
  5. import openai
  6. from common.log import logger
  7. from voice.voice import Voice
  8. class OpenaiVoice(Voice):
  9. def __init__(self):
  10. pass
  11. def voiceToText(self, voice_file):
  12. file = open(voice_file, "rb")
  13. reply = openai.Audio.transcribe("whisper-1", file)
  14. json_dict = json.loads(reply)
  15. text = json_dict['text']
  16. logger.info(
  17. '[Openai] voiceToText text={} voice file name={}'.format(text, voice_file))
  18. return text
  19. def textToVoice(self, text):
  20. pass