关于Python中install edge_tts记录

如下代码:

python 复制代码
#!/usr/bin/env python3

"""
Basic audio streaming example.

This example shows how to stream the audio data from the TTS engine,
and how to get the WordBoundary events from the engine (which could
be ignored if not needed).

The example streaming_with_subtitles.py shows how to use the
WordBoundary events to create subtitles using SubMaker.
"""

import asyncio
import edge_tts

TEXT = "Hello World!"
VOICE = "en-GB-SoniaNeural"
OUTPUT_FILE = "test.mp3"


async def amain() -> None:
    """Main function"""
    communicate = edge_tts.Communicate(TEXT, VOICE)
    with open(OUTPUT_FILE, "wb") as file:
        async for chunk in communicate.stream():
            if chunk["type"] == "audio":
                file.write(chunk["data"])
            elif chunk["type"] == "WordBoundary":
                print(f"WordBoundary: {chunk}")


if __name__ == "__main__":
    asyncio.run(amain())

要求 impoty edge_tts

通过命令行pip3 install edge_tts虽然提示导入成功,但是引用时发现提示不能使用。

经过无数次的install 和 uninstall 均不成功

最后通过也面操作成功,记录如下:

1、首先发现使用pip3 install 安装提示成功后

这个地方没有edge_tts Lib,(上图是最后安装成功的图版)

2、通过功能进行安装(最后成功)

这样安装后,在代码中才可以使用。不知道为什么会这样????

相关推荐
跃渊Yuey2 分钟前
【MySQL】MySQL库的操作
数据库·mysql
weixin_408717774 分钟前
PHP8.1新特性对AI开发帮助_JIT编译优势【解答】
jvm·数据库·python
瀚高PG实验室5 分钟前
瀚高数据库安全版4.5.10及其以上版本使用pg_cron定时任务
服务器·数据库·瀚高数据库
Ares-Wang6 分钟前
flask》》多线程并发数据安全问题 threading.local werkzeug.local.Local
后端·python·flask
2401_871696529 分钟前
golang如何实现Trie前缀树_golang Trie前缀树实现解析
jvm·数据库·python
做个文艺程序员12 分钟前
Claude Skill 进阶:多文件结构、脚本集成与触发优化
人工智能·python·开源
覆东流14 分钟前
第2天:Python变量与数据类型
开发语言·后端·python
2401_8877245015 分钟前
Go语言怎么做HTTP连接池_Go语言HTTP连接池教程【基础】
jvm·数据库·python
yuanzhengme16 分钟前
MySQL【部署 04】Docker部署 MySQL8.0.32 版本(网盘镜像及启动命令分享)
数据库·mysql·docker
qq_3345635518 分钟前
Redis怎样实现Session的分布式共享
jvm·数据库·python