Bcut-ASR
使用必剪 API 进行云端语音字幕识别,支持 CLI 和 module 调用
✨Feature
- 可直接上传
flac,aac,m4a,mp3,wav音频格式 - 自动调用 ffmpeg, 实现视频伴音和其他音频格式转码
- 支持
srt,json,lrc,txt格式字幕输出 - 字幕支持断句和首位时间标记
- 可使用 stdout 输出字幕文本
🚀Install
首先确保 ffmpeg 已安装,且 PATH 中可以访问,若未安装可以使用如下命令(已安装请无视):
Linux:
sudo apt install ffmpeg
Windows:
winget install ffmpeg
本项目暂时未发布 pypi,应使用本地安装,Python 版本应 >= 3.10,需要安装 poetry
git clone https://github.com/SocialSisterYi/bcut-asr
cd bcut-asr
poetry lock
poetry build -f wheel
pip install dist/bcut_asr-0.0.3-py3-none-any.whl # Example
📃Usage
CLI Interface
bcut_asr video.mp4
或
bcut_asr video.mp4 subtitle.srt
或
bcut_asr video.mp4 -f srt - > subtitle.srt
长音频指定任务状态轮询间隔(秒),避免接口频繁调用
bcut_asr video.mp4 -f srt -i 30 - > subtitle.srt
bcut_asr -h
usage: bcut-asr [-h] [-f [{srt,json,lrc,txt}]] [-i [1.0]] input [output]
必剪语音识别
positional arguments:
input 输入媒体文件
output 输出字幕文件, 可stdout
options:
-h, --help show this help message and exit
-f [{srt,json,lrc,txt}], --format [{srt,json,lrc,txt}]
输出字幕格式
-i [1.0], --interval [1.0]
任务状态轮询间隔(秒)
支持输入音频格式: flac, aac, m4a, mp3, wav 支持自动调用ffmpeg提取视频伴音
Module
from bcut_asr import BcutASR
from bcut_asr.orm import ResultStateEnum
asr = BcutASR('voice.mp3')
asr.upload() # 上传文件
asr.create_task() # 创建任务
# 轮询检查结果
while True:
result = asr.result()
# 判断识别成功
if result.state == ResultStateEnum.COMPLETE:
break
# 解析字幕内容
subtitle = result.parse()
# 判断是否存在字幕
if subtitle.has_data():
# 输出srt格式
print(subtitle.to_srt())
输入视频
from bcut_asr import run_everywhere
from argparse import Namespace
f = open("file.mp4", "rb")
argg = Namespace(format="srt", interval=30.0, input=f, output=None)
run_everywhere(argg)
Metadata
Release files for bcut-asr-branch 0.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bcut_asr_branch-0.0.3-py3-none-any.whl | Python 3 | none | any | Details for bcut_asr_branch-0.0.3-py3-none-any.whl |
Release files / bcut_asr_branch-0.0.3-py3-none-any.whl
| Download URL | bcut_asr_branch-0.0.3-py3-none-any.whl |
|---|---|
| Size | 9.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e8dbfc55a6ea5abd8bb670297cfcc6211e35117367e883992b204c8e7775a691
|
|
BLAKE2b-256 checksum How to use checksums |
f11ddd5760d371b9fdc38afc66b9b838e38aef9d1768b27273c91c9671e2df8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.2 CPython/3.11.5 Windows/10
|
Security for bcut-asr-branch 0.0.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.