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

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

相关推荐
进击的明明8 小时前
当AI开始“边想边干”:深入聊聊ReAct,以及如何用Python手搓一个简单Agent
python·面试·agent
这个DBA有点耶9 小时前
从症状到根因:数据库监控指标的分层方法与静态/动态阈值策略
数据库·mysql·代码规范
全栈弄潮儿9 小时前
Python实战第8期:函数
后端·python·编程语言
SelectDB9 小时前
时间旅行与快照能力速查:Doris 侧三条落地路径
大数据·数据库·数据分析
SelectDB9 小时前
云数仓成本结构拆解速查:五层计费 vs Doris / 托管形态
大数据·数据库·数据分析
SelectDB9 小时前
什么场景能承接与建议保留:Doris vs Snowflake 边界速查
大数据·数据库·数据分析
卷无止境11 小时前
暗流与破局:AI时代的代码安全审查工具全景指南
后端·python
这个DBA有点耶11 小时前
DELETE没删多少数据,表却越来越大——InnoDB删除空洞与页合并失效的根因
数据库·mysql·代码规范
卷无止境13 小时前
一人公司的全栈选型指南:让 AI Agent 写得快,也让生意跑得稳
后端·python