Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

12345678910111213141516171819202122232425
  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