Giter VIP home page Giter VIP logo

bcut-asr's Introduction

Bcut-ASR

使用必剪 API 进行云端语音字幕识别,支持 CLI 和 module 调用

Feature

  • 可直接上传flac, aac, m4a, mp3, wav音频格式
  • 自动调用ffmpeg, 实现视频伴音和其他音频格式转码
  • 支持srt, json, lrc, txt格式字幕输出
  • 字幕支持断句和首位时间标记
  • 可使用 stdout 输出字幕文本

Install

git clone https://github.com/SocialSisterYi/bcut-asr
cd bcut-asr
./setup.py install

媒体转码需要安装 ffmpeg, 且系统 PATH 中可访问

Usage

CLI Interface

bcut_asr video.mp4

bcut_asr video.mp4 subttle.srt

bcut_asr video.mp4 -f srt - > subttle.srt
bcut_asr -h                
usage: bcut_asr [-h] [-f [{srt,json,lrc,txt}]] 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}]
                        输出字幕格式

支持输入音频格式: 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", input=f, output=None)
run_everywhere(argg)

bcut-asr's People

Contributors

socialsisteryi avatar weltolk avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.