whisperspeech 英文TTS的实现

以下代码成功运行在 colab 中,需要修改运行时类型为 T4 GPU

python 复制代码
!pip install -Uqq WhisperSpeech
def is_colab():
    try: import google.colab; return True
    except: return False

import torch
# if not torch.cuda.is_available():
#     if is_colab(): raise BaseException("Please change the runtime type to GPU. In the menu: Runtime -> Change runtime type (the free T4 instance is enough)")
#     else:          raise BaseException("Currently the example notebook requires CUDA, make sure you are running this on a machine with a GPU.")

# %load_ext autoreload
# %autoreload 2

import torch
import torch.nn.functional as F

from IPython.display import Markdown, HTML

# check "7. Pipeline.ipynb"
from whisperspeech.pipeline import Pipeline

pipe = Pipeline(s2a_ref='collabora/whisperspeech:s2a-q4-tiny-en+pl.model')

# pipe.generate_to_notebook("""
# This is the first demo of Whisper Speech, a fully open source text-to-speech model trained by Collabora and Lion on the Juwels supercomputer.
# """)

pipe.generate_to_notebook("""
History will not look kindly on House Republicans for their blatant act of unconstitutional partisanship 
that has targeted an honorable public servant in order to play petty political games. Homeland Security Secretary Mayorkas, 
a Cuban immigrant who came to the United States with his family as political refugees, has spent more than two decades serving America 
with integrity in a decorated career in law enforcement and public service.
""")

#也可以保存到文件:
# pipe.generate_to_file("output.wav", "This is the first demo of Whisper Speech, a fully open source text-to-speech model # trained by Collabora and Lion on the Juwels supercomputer")
相关推荐
沐知全栈开发8 分钟前
ionic 手势事件详解
开发语言
用户83562907805111 分钟前
用 Python 轻松在 Excel 工作表中应用条件格式
后端·python
red1giant_star16 分钟前
Python根据文件后缀统计文件大小、找出文件位置(仿Everything)
后端·python
端平入洛20 分钟前
梯度是什么:PyTorch 自动求导详解
人工智能·深度学习
雷欧力28 分钟前
如何使用 Claude API?3 种接入方案实测,附完整代码(2026)
python·claude
lsx20240629 分钟前
Bootstrap 按钮
开发语言
神仙别闹32 分钟前
基于 Python 实现 BERT 的情感分析模型
开发语言·python·bert
Uopiasd1234oo37 分钟前
上下文引导模块改进YOLOv26局部与全局特征融合能力双重提升
深度学习·yolo·机器学习
禾叙_38 分钟前
【langchain4j】结构化输出(六)
java·开发语言
NQBJT39 分钟前
VS Code配置Python人工智能开发环境
开发语言·人工智能·vscode·python