mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-03-18 12:40:06 +08:00
Merge pull request #1871 from cgnannan/master
修复 Issues #1868提到的elevenlabs sdk更新问题
This commit is contained in:
@@ -10,6 +10,7 @@ azure-cognitiveservices-speech # azure voice
|
|||||||
edge-tts # edge-tts
|
edge-tts # edge-tts
|
||||||
numpy<=1.24.2
|
numpy<=1.24.2
|
||||||
langid # language detect
|
langid # language detect
|
||||||
|
elevenlabs==1.0.3 # elevenlabs TTS
|
||||||
|
|
||||||
#install plugin
|
#install plugin
|
||||||
dulwich
|
dulwich
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
|
|
||||||
from elevenlabs import set_api_key,generate
|
from elevenlabs.client import ElevenLabs
|
||||||
|
from elevenlabs import save
|
||||||
from bridge.reply import Reply, ReplyType
|
from bridge.reply import Reply, ReplyType
|
||||||
from common.log import logger
|
from common.log import logger
|
||||||
from common.tmp_dir import TmpDir
|
from common.tmp_dir import TmpDir
|
||||||
@@ -9,7 +9,7 @@ from voice.voice import Voice
|
|||||||
from config import conf
|
from config import conf
|
||||||
|
|
||||||
XI_API_KEY = conf().get("xi_api_key")
|
XI_API_KEY = conf().get("xi_api_key")
|
||||||
set_api_key(XI_API_KEY)
|
client = ElevenLabs(api_key=XI_API_KEY)
|
||||||
name = conf().get("xi_voice_id")
|
name = conf().get("xi_voice_id")
|
||||||
|
|
||||||
class ElevenLabsVoice(Voice):
|
class ElevenLabsVoice(Voice):
|
||||||
@@ -21,13 +21,12 @@ class ElevenLabsVoice(Voice):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def textToVoice(self, text):
|
def textToVoice(self, text):
|
||||||
audio = generate(
|
audio = client.generate(
|
||||||
text=text,
|
text=text,
|
||||||
voice=name,
|
voice=name,
|
||||||
model='eleven_multilingual_v1'
|
model='eleven_multilingual_v2'
|
||||||
)
|
)
|
||||||
fileName = TmpDir().path() + "reply-" + str(int(time.time())) + "-" + str(hash(text) & 0x7FFFFFFF) + ".mp3"
|
fileName = TmpDir().path() + "reply-" + str(int(time.time())) + "-" + str(hash(text) & 0x7FFFFFFF) + ".mp3"
|
||||||
with open(fileName, "wb") as f:
|
save(audio, fileName)
|
||||||
f.write(audio)
|
|
||||||
logger.info("[ElevenLabs] textToVoice text={} voice file name={}".format(text, fileName))
|
logger.info("[ElevenLabs] textToVoice text={} voice file name={}".format(text, fileName))
|
||||||
return Reply(ReplyType.VOICE, fileName)
|
return Reply(ReplyType.VOICE, fileName)
|
||||||
Reference in New Issue
Block a user