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

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

相关推荐
2301_796588505 小时前
PHP源码能否在无盘工作站运行_网络启动硬件要求【说明】
jvm·数据库·python
小糖学代码5 小时前
LLM系列:2.pytorch入门:7.深层神经网络
人工智能·pytorch·python·深度学习·神经网络
qq_424098565 小时前
CSS如何让文字超出两行显示省略号_使用line-clamp属性限制
jvm·数据库·python
qq_372906935 小时前
如何重命名SQL触发器名称_使用sp_rename重新定义标识
jvm·数据库·python
解救女汉子5 小时前
SQL如何统计每日新增用户数_窗口函数与日期维度的结合
jvm·数据库·python
E_ICEBLUE5 小时前
在 Python 中自动化转化 Markdown 为 HTML 【详细教程】
python·自动化·html
djjdjdjdjjdj5 小时前
PyTorch bfloat16 张量转 NumPy 的兼容性解决方案
jvm·数据库·python
Greyson15 小时前
实现 Flex 容器内子元素自适应高度并启用自动滚动
jvm·数据库·python
xyghehehehe5 小时前
【MySQL深入详解】第11篇:内存与IO配置——InnoDB核心参数调优
数据库
m0_596406375 小时前
Redis如何配置主从复制关系_利用REPLICAOF命令将节点挂载至主节点
jvm·数据库·python