Commit bd033ee7 authored by Mattia Bergagio's avatar Mattia Bergagio
Browse files

cleanup

parent 23ca7d86
```
cd $PATH_SHARED
mkdir models
cd models
mkdir mmc_asr
cd mmc_asr
git lfs install
git clone https://huggingface.co/openai/whisper-large-v3
```
import torch
from transformers import pipeline
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
class AutomaticSpeechRecognition():
QuestionAudio = None
##
QuestionText = None
def funcAutomaticSpeechRecognition(self, input):
'''
Verify the inference
'''
speech_reco = pipeline(
"automatic-speech-recognition", model="openai/whisper-base", device=device
)
res = speech_reco(input)
return res["text"]
def run(self):
self.QuestionText = self.funcAutomaticSpeechRecognition(self.QuestionAudio)
if __name__ == '__main__':
module = AutomaticSpeechRecognition()
module.QuestionAudio = "path/to/audiofile"
module.run()
print(module.QuestionText)
Implementation of MMC-ASR as a class in Python.
## Installation
Code was designed and tested on an Ubuntu 20.04 operating system using anaconda 23.7.2 and Python 3.9.
An environment with all the necessary libraries can be created using:
```bash
conda create --name <env> --file requirements.txt
```
# MPAI-MMC Automatic Speech Recognition
This code refers to the implementation of the MMC-ASR, as described in the [AIM](https://mpai.community/standards/mpai-mmc/v2-2/ai-modules/automatic-speech-recognition/).
### Guide to the ASR code #1
The code takes Speech Objects from MMC-AUS and generates Text Segments (called text transcripts). It uses the whisper-large-v3 model to convert an input Speech Object (speaker’s turn) into a Text Segment (here called text transcript). Disfluencies (e.g., repetitions, repairs, filled pauses) are often omitted. The Whisper reference document is available.
The MMC-ASR Reference Software is found at the MPAI gitlab site. Use of this AI Modules is for developers who are familiar with Python, Docker, RabbitMQ, and downloading models from HuggingFace. The Reference Software contains:
......@@ -16,18 +13,14 @@ The MMC-ASR Reference Software is found at the MPAI gitlab site. Use of this AI
Library: https://github.com/linto-ai/whisper-timestamped
### Guide to the ASR code #2
Use of this AI Modules is for developers who are familiar with Python and downloading models from HuggingFace,
A wrapper for the Whisper NN Module:
1. Manages input files and parameters: Speech Object
2. Performs Speech Recognition on each Speech Object by executing the Whisper Module.
3. Outputs Recognised Text.
The MMC-ASR Reference Software is found at the NNW gitlab site (registration required). It contains:
1. The python code implementing the AIM.
2. The required libraries are: pytorch and transformers (HuggingFace).
How to download the aforesaid model:
```
cd $PATH_SHARED
mkdir models
cd models
mkdir mmc_asr
cd mmc_asr
git lfs install
git clone https://huggingface.co/openai/whisper-large-v3
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment