Name | bcut-asr-branch JSON |
Version |
0.0.3
JSON |
| download |
home_page | None |
Summary | 使用必剪API的语音字幕识别 |
upload_time | 2024-05-04 05:52:05 |
maintainer | None |
docs_url | None |
author | SocialSisterYi |
requires_python | >=3.10 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<h1 align="center">Bcut-ASR</h1>
使用必剪 API 进行云端语音字幕识别,支持 CLI 和 module 调用
## ✨Feature
- 可直接上传`flac`, `aac`, `m4a`, `mp3`, `wav`音频格式
- 自动调用 ffmpeg, 实现视频伴音和其他音频格式转码
- 支持`srt`, `json`, `lrc`, `txt`格式字幕输出
- 字幕支持断句和首位时间标记
- 可使用 stdout 输出字幕文本
## 🚀Install
首先确保 ffmpeg 已安装,且 PATH 中可以访问,若未安装可以使用如下命令(已安装请无视):
Linux:
```bash
sudo apt install ffmpeg
```
Windows:
```powershell
winget install ffmpeg
```
本项目暂时未发布 pypi,应使用本地安装,Python 版本应 >= 3.10,需要安装 poetry
```bash
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
```bash
bcut_asr video.mp4
```
或
```bash
bcut_asr video.mp4 subtitle.srt
```
或
```bash
bcut_asr video.mp4 -f srt - > subtitle.srt
```
长音频指定任务状态轮询间隔(秒),避免接口频繁调用
```bash
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
```python
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())
```
输入视频
```python
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)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "bcut-asr-branch",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": null,
"author": "SocialSisterYi",
"author_email": "1440239038@qq.com",
"download_url": null,
"platform": null,
"description": "<h1 align=\"center\">Bcut-ASR</h1>\n\n\u4f7f\u7528\u5fc5\u526a API \u8fdb\u884c\u4e91\u7aef\u8bed\u97f3\u5b57\u5e55\u8bc6\u522b\uff0c\u652f\u6301 CLI \u548c module \u8c03\u7528\n\n## \u2728Feature\n\n- \u53ef\u76f4\u63a5\u4e0a\u4f20`flac`, `aac`, `m4a`, `mp3`, `wav`\u97f3\u9891\u683c\u5f0f\n- \u81ea\u52a8\u8c03\u7528 ffmpeg, \u5b9e\u73b0\u89c6\u9891\u4f34\u97f3\u548c\u5176\u4ed6\u97f3\u9891\u683c\u5f0f\u8f6c\u7801\n- \u652f\u6301`srt`, `json`, `lrc`, `txt`\u683c\u5f0f\u5b57\u5e55\u8f93\u51fa\n- \u5b57\u5e55\u652f\u6301\u65ad\u53e5\u548c\u9996\u4f4d\u65f6\u95f4\u6807\u8bb0\n- \u53ef\u4f7f\u7528 stdout \u8f93\u51fa\u5b57\u5e55\u6587\u672c\n\n## \ud83d\ude80Install\n\n\u9996\u5148\u786e\u4fdd ffmpeg \u5df2\u5b89\u88c5\uff0c\u4e14 PATH \u4e2d\u53ef\u4ee5\u8bbf\u95ee\uff0c\u82e5\u672a\u5b89\u88c5\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u547d\u4ee4\uff08\u5df2\u5b89\u88c5\u8bf7\u65e0\u89c6\uff09\uff1a\n\nLinux\uff1a\n\n```bash\nsudo apt install ffmpeg\n```\n\nWindows\uff1a\n\n```powershell\nwinget install ffmpeg\n```\n\n\u672c\u9879\u76ee\u6682\u65f6\u672a\u53d1\u5e03 pypi\uff0c\u5e94\u4f7f\u7528\u672c\u5730\u5b89\u88c5\uff0cPython \u7248\u672c\u5e94 >= 3.10\uff0c\u9700\u8981\u5b89\u88c5 poetry \n\n```bash\ngit clone https://github.com/SocialSisterYi/bcut-asr\ncd bcut-asr\npoetry lock\npoetry build -f wheel\npip install dist/bcut_asr-0.0.3-py3-none-any.whl # Example\n```\n\n## \ud83d\udcc3Usage\n\n### CLI Interface\n\n```bash\nbcut_asr video.mp4\n```\n\n\u6216\n\n```bash\nbcut_asr video.mp4 subtitle.srt\n```\n\n\u6216\n\n```bash\nbcut_asr video.mp4 -f srt - > subtitle.srt\n```\n\n\u957f\u97f3\u9891\u6307\u5b9a\u4efb\u52a1\u72b6\u6001\u8f6e\u8be2\u95f4\u9694(\u79d2)\uff0c\u907f\u514d\u63a5\u53e3\u9891\u7e41\u8c03\u7528\n\n```bash\nbcut_asr video.mp4 -f srt -i 30 - > subtitle.srt\n```\n\n```\nbcut_asr -h\nusage: bcut-asr [-h] [-f [{srt,json,lrc,txt}]] [-i [1.0]] input [output]\n\n\u5fc5\u526a\u8bed\u97f3\u8bc6\u522b\n\npositional arguments:\n input \u8f93\u5165\u5a92\u4f53\u6587\u4ef6\n output \u8f93\u51fa\u5b57\u5e55\u6587\u4ef6, \u53efstdout\n\noptions:\n -h, --help show this help message and exit\n -f [{srt,json,lrc,txt}], --format [{srt,json,lrc,txt}]\n \u8f93\u51fa\u5b57\u5e55\u683c\u5f0f\n -i [1.0], --interval [1.0]\n \u4efb\u52a1\u72b6\u6001\u8f6e\u8be2\u95f4\u9694(\u79d2)\n\n\u652f\u6301\u8f93\u5165\u97f3\u9891\u683c\u5f0f: flac, aac, m4a, mp3, wav \u652f\u6301\u81ea\u52a8\u8c03\u7528ffmpeg\u63d0\u53d6\u89c6\u9891\u4f34\u97f3\n```\n\n### Module\n\n```python\nfrom bcut_asr import BcutASR\nfrom bcut_asr.orm import ResultStateEnum\n\nasr = BcutASR('voice.mp3')\nasr.upload() # \u4e0a\u4f20\u6587\u4ef6\nasr.create_task() # \u521b\u5efa\u4efb\u52a1\n\n# \u8f6e\u8be2\u68c0\u67e5\u7ed3\u679c\nwhile True:\n result = asr.result()\n # \u5224\u65ad\u8bc6\u522b\u6210\u529f\n if result.state == ResultStateEnum.COMPLETE:\n break\n\n# \u89e3\u6790\u5b57\u5e55\u5185\u5bb9\nsubtitle = result.parse()\n# \u5224\u65ad\u662f\u5426\u5b58\u5728\u5b57\u5e55\nif subtitle.has_data():\n # \u8f93\u51fasrt\u683c\u5f0f\n print(subtitle.to_srt())\n```\n\n\u8f93\u5165\u89c6\u9891\n\n```python\nfrom bcut_asr import run_everywhere\nfrom argparse import Namespace\n\n\nf = open(\"file.mp4\", \"rb\")\nargg = Namespace(format=\"srt\", interval=30.0, input=f, output=None)\nrun_everywhere(argg)\n\n```\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "\u4f7f\u7528\u5fc5\u526aAPI\u7684\u8bed\u97f3\u5b57\u5e55\u8bc6\u522b",
"version": "0.0.3",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f11ddd5760d371b9fdc38afc66b9b838e38aef9d1768b27273c91c9671e2df8a",
"md5": "58107500ad76389180f65adb51421f6e",
"sha256": "e8dbfc55a6ea5abd8bb670297cfcc6211e35117367e883992b204c8e7775a691"
},
"downloads": -1,
"filename": "bcut_asr_branch-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "58107500ad76389180f65adb51421f6e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10",
"size": 9901,
"upload_time": "2024-05-04T05:52:05",
"upload_time_iso_8601": "2024-05-04T05:52:05.502868Z",
"url": "https://files.pythonhosted.org/packages/f1/1d/dd5760d371b9fdc38afc66b9b838e38aef9d1768b27273c91c9671e2df8a/bcut_asr_branch-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-04 05:52:05",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "bcut-asr-branch"
}