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

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

相关推荐
Dxy12393102165 分钟前
MySQL性能优化深度解析
数据库·mysql·性能优化
铁锚9 分钟前
Redis中KEYS命令的潜在风险与遍历建议
数据库·redis·缓存
ㄣ知冷煖★22 分钟前
基于openEuler操作系统的图神经网络应用开发:以Cora数据集节点分类为例的研究与实践
python
清晓粼溪25 分钟前
MySQL-01:基础知识
数据库·mysql
贝塔实验室26 分钟前
Altium Designer 集成库介绍
arm开发·数据库·驱动开发·硬件工程·射频工程·基带工程·精益工程
祝余Eleanor29 分钟前
Day32 深入理解SHAP图
人工智能·python·机器学习
哈哈老师啊30 分钟前
Springboot学生接送服务平台8rzvo(程序+源码+数据库+调试部署+开发环境)带论文文档1万字以上,文末可获取,系统界面在最后面。
数据库·spring boot·后端
VX:Fegn089531 分钟前
计算机毕业设计|基于springboot + vue图书商城系统(源码+数据库+文档)
数据库·vue.js·spring boot·后端·课程设计
思成不止于此33 分钟前
MySQL 基础核心知识点全梳理:从入门到实战
数据库·笔记·学习·mysql
int WINGsssss1 小时前
【无标题】
pytorch·分布式·python