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

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

相关推荐
非鱼feiyu3 分钟前
自关联数据表查询优化实践:以 Django + 递归 CTE 构建树结构为例
数据库·后端·django
零日失眠者9 分钟前
这5个Python库一旦掌握就离不开
后端·python
用户83562907805115 分钟前
如何使用 Python 从 Word 文档中批量提取表格数据
后端·python
寻找华年的锦瑟24 分钟前
Qt-QStackedWidget
java·数据库·qt
Jerryhut42 分钟前
sklearn函数总结四——归一化和标准化
人工智能·python·机器学习·jupyter·sklearn
带带弟弟学爬虫__42 分钟前
ks安卓—did注册
前端·javascript·vue.js·python·网络爬虫
F***E2391 小时前
SQL中的REGEXP正则表达式使用指南
数据库·sql·正则表达式
张较瘦_1 小时前
数据库 | 从宠物管理系统看懂数据库多表关联查询:把零散的数据“串”起来
数据库·oracle·宠物
Q_Q19632884751 小时前
python+django/flask+vue的多媒体素材管理系统
spring boot·python·django·flask·node.js·php
我要学脑机1 小时前
一个jupyter组件的信号查看工具
python·jupyter