Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

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