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

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

相关推荐
marvelyu3 小时前
每天10分钟学会OceanBase系列(Day 20):跨机房容灾实战——构建多数据中心高可用架构
java·大数据·数据库
ZCBUS实时计算3 小时前
金融证券实时数仓建设实践:轻量化实时计算平台落地,实现交易数据端到端秒级处理
大数据·数据库·数据仓库·金融·flink·dba·etl
zd2005723 小时前
海洋微生物数据库
数据库·宏基因组
今儿敲了吗3 小时前
Python ——第三方包
笔记·python
麒麟水手3 小时前
国产银河麒麟系统开发实录:跑通Streamlit,我踩过的6个坑
python
海上小飞龙3 小时前
Redis 分布式锁原理:从 SET NX EX 到 Redisson 看门狗
数据库·redis·分布式
麒麟水手4 小时前
麒麟系统部署检查清单:上线前30分钟,逐项自查这4类问题
python
xiaoye-duck4 小时前
MySQL 表约束全解:从基础约束到外键关联规则
数据库·mysql
Hammer_Hans4 小时前
DFT笔记98
java·开发语言·数据库
用户0332126663675 小时前
使用 Python 在 PDF 中添加或删除数字签名
python