Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

33 lignes
762B

  1. """
  2. eleventLabs voice service
  3. """
  4. import time
  5. from elevenlabs import generate
  6. from bridge.reply import Reply, ReplyType
  7. from common.log import logger
  8. from common.tmp_dir import TmpDir
  9. from voice.voice import Voice
  10. class ElevenLabsVoice(Voice):
  11. def __init__(self):
  12. pass
  13. def voiceToText(self, voice_file):
  14. pass
  15. def textToVoice(self, text):
  16. audio = generate(
  17. text=text
  18. )
  19. fileName = TmpDir().path() + "reply-" + str(int(time.time())) + "-" + str(hash(text) & 0x7FFFFFFF) + ".mp3"
  20. with open(fileName, "wb") as f:
  21. f.write(audio)
  22. logger.info("[ElevenLabs] textToVoice text={} voice file name={}".format(text, fileName))
  23. return Reply(ReplyType.VOICE, fileName)