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

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

相关推荐
014-code29 分钟前
MySQL 常用业务 SQL
数据库·sql·mysql
知识分享小能手41 分钟前
MongoDB入门学习教程,从入门到精通,MongoDB的选择片键 - 完整知识点(16)
数据库·学习·mongodb
知识分享小能手1 小时前
MongoDB入门学习教程,从入门到精通,MongoDB分片配置完全指南(15)
数据库·学习·mongodb
soragui1 小时前
【Python】第 4 章:Python 数据结构实现
数据结构·windows·python
y = xⁿ1 小时前
【MySQL】数据库的脏读,不可重复读和幻读,覆盖索引是什么,索引类型有哪些
数据库·mysql
小冷coding1 小时前
【面试】结合项目整理的场景面试题,覆盖 Java 基础、锁、多线程、数据库、分布式锁 / 事务、消息中间件等核心维度
java·数据库·面试
和小潘一起学AI1 小时前
CentOS 7安装Anaconda
开发语言·python
kcuwu.1 小时前
Python 正则表达式从入门到实战
数据库·python·正则表达式
不解不惑1 小时前
langchain qwen3 构建一个简单的对话系统
pytorch·python·langchain