mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-04-18 10:02:43 +08:00
[voice] add support for wispper
This commit is contained in:
25
voice/openai/openai_voice.py
Normal file
25
voice/openai/openai_voice.py
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
"""
|
||||
google voice service
|
||||
"""
|
||||
import json
|
||||
import openai
|
||||
from common.log import logger
|
||||
from voice.voice import Voice
|
||||
|
||||
|
||||
class OpenaiVoice(Voice):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def voiceToText(self, voice_file):
|
||||
file = open(voice_file, "rb")
|
||||
reply = openai.Audio.transcribe("whisper-1", file)
|
||||
json_dict = json.loads(reply)
|
||||
text = json_dict['text']
|
||||
logger.info(
|
||||
'[Openai] voiceToText text={} voice file name={}'.format(text, voice_file))
|
||||
return text
|
||||
|
||||
def textToVoice(self, text):
|
||||
pass
|
||||
Reference in New Issue
Block a user