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

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

相关推荐
时光Autistic2 小时前
【安装教程】AI标注工具X-AnyLabeling安装配置
人工智能·python
knight_9___2 小时前
大模型project面试7
人工智能·python·算法·面试·大模型·agent
yuhuofei20212 小时前
【Python入门】Python与PyCharm的安装
开发语言·python·pycharm
吴声子夜歌2 小时前
Java——类加载机制
java·开发语言·python
j7~2 小时前
【MYSQL】在Centos7和ubuntu22.04环境下安装
数据库·c++·mysql·ubuntu·centos
环流_2 小时前
redis:持久化rdb
java·数据库·redis
Donk_672 小时前
MariaDB 数据库管理手册
数据库·mariadb
阿洛学长2 小时前
PostgreSQL 超详细安装与使用教程:从入门到实战
数据库·postgresql
许彰午3 小时前
Oracle Redo日志与Undo回滚段损坏恢复实战
数据库·oracle
qxwlcsdn3 小时前
mysql在事务中执行DDL的后果_MySQL 8.0之前的限制
jvm·数据库·python