alphacep / alphacep/vosk-api

Add arguments `time_off` and `duration` to transcriber

未关闭
#1,533 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Jupyter Notebook
星标
15.1k
派生
1.8k
PR 合并指标
30 天内没有已合并 PR

描述

Currently the transcriber processes the whole input file. From the beginning to the end.

It would be very useful to be able to pass a start time offset and/or a duration to the transcriber.

Here is a proposal how to do it:

Add (ffmpeg's) arguments `time_off` and `duration` in `python/vosk/transcriber/cli.py` after line 46.

```python
parser.add_argument("--time_off", "-ss", default=None, type=int, help="start time offset")
parser.add_argument("--duration", "-d", default=None, type=int, help="duration")
```

Pass the arguments `time_off` and `duration` to ffmpeg in function `resample_ffmpeg` in `python/vosk/transcriber/transcriber.py` (line 115):

```python
cmd = shlex.split("ffmpeg -nostdin -loglevel quiet "
"-i \'{}\' -ar {} -ac 1 {} {} -f s16le -".format(
str(infile),
SAMPLE_RATE,
f'-ss {self.args.time_off}' if self.args.time_off is not None else '', # add this
f'-t {self.args.duration}' if self.args.duration is not None else '' # and this
))
```

The function `resample_ffmpeg_async` could be adapted similarly.

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。