選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

openai_voice.py 565B

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