python - 如何给 OpenAI 的 Whisper ASR 一些提示短语?

标签 python speech-recognition openai-api openai-whisper hint-phrases

我使用 OpenAI 的 Whisper用于语音识别的 python 库。我怎样才能给出一些提示短语,因为它可以用其他一些 ASR 来完成,例如 Google


用 OpenAI 的 Whisper 转录(在带有 Nvidia GeForce RTX 3090 的 Ubuntu 20.04 x64 LTS 上测试):

conda create -y --name whisperpy39 python==3.9
conda activate whisperpy39
pip install git+https://github.com/openai/whisper.git 
sudo apt update && sudo apt install ffmpeg
whisper recording.wav
whisper recording.wav --model large

如果使用 Nvidia GeForce RTX 3090,请在 conda activate whisperpy39 之后添加以下内容:

pip install -f https://download.pytorch.org/whl/torch_stable.html
conda install pytorch==1.10.1 torchvision torchaudio cudatoolkit=11.0 -c pytorch

最佳答案

提示短语/提升的 2 个潜在位置:

  1. https://github.com/openai/whisper/blob/15ab54826343c27cfaf44ce31e9c8fb63d0aa775/whisper/decoding.py#L87-L88 :在 prompt 中添加提示短语(而不是在 prefix 中:请参阅此 discussion 关于 promptprefix。有一个 new --initial_promptcommit 2037b65 选项:

    whisper audio.mp3 --initial\_prompt "So we were just talking about DALL·E"
    
  2. https://github.com/openai/whisper/blob/15ab54826343c27cfaf44ce31e9c8fb63d0aa775/whisper/decoding.py#L302 :更改代码以增加包含提示短语的序列的可能性,e.g. :

    Currently there's no interface for this other than giving the initial_prompt like the above; you could hack something with logit biasing, that effectively boosts the predicted probability of certain tokens. The LogitFilter class is designed to support this.

我不知道它的效率如何。此外,当提示词不在词典中时,会出现一个潜在问题,在这种情况下,需要将提示词添加到词典中,这可能很困难。

关于python - 如何给 OpenAI 的 Whisper ASR 一些提示短语?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73833916/

相关文章:

python 编码问题\ufeff in pandas 列名

javax.sound.sampled.LineUnavailableException : line with format PCM_SIGNED 16000. 0 Hz,16 位,单声道,2 字节/帧

openai-api - OpenAI ChatGPT (GPT-3.5) API : Can I fine-tune the gpt-3. 5-turbo 模型?

javascript - 如何指定 OpenAI 完成应返回的最大字数

php - 如何使用 OpenAI API PHP sdk 保持对话

python - 使用 Rest Api 和 DataBricks CLI 创建 DataBricks Azure Key Vault secret 范围后端

python - 如何获取包含 Pyspark Dataframe 中另一列中给出的多列值的列表列?

javascript - 如何在ajax调用后重新加载CSS

ios - 音频引擎在停止时崩溃

java - 在哪里可以找到并下载 Java Speech API?