Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python出了个edge-TTS,可以免费、无限量合成非常接近人的语音。可以加上吗? #233

Closed
prairiewolf11 opened this issue Apr 8, 2023 · 3 comments
Assignees
Labels
enhancement 好想法,以后考虑跟进

Comments

@prairiewolf11
Copy link

prairiewolf11 commented Apr 8, 2023

import edge_tts
import asyncio

voice = 'zh-CN-XiaoxiaoNeural'
rate = '-4%'
volume = '+0%'
async def edgeTTS(TEXT,audiofile):
tts = edge_tts.Communicate(text = TEXT,voice = voice,rate = rate,volume=volume)
await tts.save(audiofile)
由于这个tts可以无限使用,所以没必要保存成音频文件,不用考虑是否命中缓存,接收到音频流就直接送去播放。这样能减少写入。

@prairiewolf11 prairiewolf11 added the operation problem 用户操作问题 label Apr 8, 2023
@wzpan wzpan added enhancement 好想法,以后考虑跟进 and removed operation problem 用户操作问题 labels Apr 8, 2023
@wzpan wzpan added this to wukong Apr 8, 2023
@github-project-automation github-project-automation bot moved this to To do in wukong Apr 8, 2023
@wzpan wzpan moved this from To do to In progress in wukong Apr 11, 2023
@prairiewolf11
Copy link
Author

prairiewolf11 commented Apr 15, 2023

能帮改改下面的代码不?这是用chatgpt写的。
from typing import Optional
import edge_tts
import asyncio

class EdgeTTS(AbstractTTS):
"""
使用edge-TTS模块语音合成
"""
SLUG = "edge-tts"

def __init__(self, voice: Optional[str] = 'zh-CN-XiaoxiaoNeural', 
                   rate: Optional[str] = '-4%', 
                   volume: Optional[str] = '+0%') -> None:
    super().__init__()
    self.voice = voice
    self.rate = rate
    self.volume = volume

async def get_speech(self, phrase: str) -> Optional[str]:
    audiofile = self._tmp_file()
    try:
        tts = edge_tts.Communicate(text=phrase, voice=self.voice, rate=self.rate, volume=self.volume)
        await tts.save(audiofile)
        return audiofile
    except Exception as e:
        self.logger.error(f"{self.SLUG} error: {str(e)}")
        return None

@wzpan
Copy link
Owner

wzpan commented Apr 16, 2023

3.5.1 版本已发布,增加了 edge-tts 的支持。详见:#243

@prairiewolf11
Copy link
Author

感谢感谢

@github-project-automation github-project-automation bot moved this from In progress to Done in wukong Apr 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement 好想法,以后考虑跟进
Projects
Status: Done
Development

No branches or pull requests

2 participants