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

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

相关推荐
努力的BigJiang4 分钟前
ORB-SLAM2在ubuntu20.04中的复现记录(跑数据集+ROS)(ROS接口失败版)
python
计算机学姐1 小时前
基于Python的商场停车管理系统【2026最新】
开发语言·vue.js·后端·python·mysql·django·flask
ujainu1 小时前
Flutter + HarmonyOS开发:轻松实现ArkTS页面跳转
人工智能·python·flutter
小猪快跑爱摄影1 小时前
【AutoCad 2025】【Python】零基础教程(一)——简单示例
开发语言·python
刺客xs1 小时前
MySQL数据库----通配符,正则表达式
数据库·mysql·正则表达式
无限大.1 小时前
计算机十万个为什么--数据库索引
数据库·oracle
秋刀鱼 ..1 小时前
【IEEE出版】第五届高性能计算、大数据与通信工程国际学术会议(ICHBC 2025)
大数据·人工智能·python·机器人·制造·新人首发
思成不止于此2 小时前
MySQL 数据操作:增删改核心语法全解析
数据库·笔记·学习·mysql
得物技术2 小时前
数据库AI方向探索-MCP原理解析&DB方向实战|得物技术
数据库
Arva .2 小时前
MySQL 的锁类型有哪些
数据库·mysql