关于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、通过功能进行安装(最后成功)

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

相关推荐
VALENIAN瓦伦尼安教学设备2 分钟前
设备对中不良的危害
数据库·嵌入式硬件·算法
sun_tao15 分钟前
LlamaIndex + Qwen3.5-4B 关闭 Thinking 模式调试记录
python·llamaindex·qwen3.5-4b·huggingfacellm
小兔崽子去哪了13 分钟前
Docker 安装 PostgreSQL
数据库·后端·postgresql
野犬寒鸦17 分钟前
Redis热点key问题解析与实战解决方案(附大厂实际方案讲解)
服务器·数据库·redis·后端·缓存·bootstrap
书到用时方恨少!22 分钟前
Python os 模块使用指南:系统交互的瑞士军刀
开发语言·python
mldlds42 分钟前
Windows安装Redis图文教程
数据库·windows·redis
带娃的IT创业者1 小时前
WeClaw_40_系统监控与日志体系:多层次日志架构与Trace追踪
java·开发语言·python·架构·系统监控·日志系统·链路追踪
Y001112361 小时前
JDBC原理
java·开发语言·数据库·jdbc
超级大只老咪1 小时前
固定个数的状态,需要按顺序无限循环切换
数据库
亓才孓1 小时前
【提示词五要素】
python·ai·prompt