Oepnsource transcribing audio and analyzing fluency, vocabulary, grammar, and topic relevancy.
Python
0
1 commits
updated May 21, 2025
Opensource transcribing audio and analyzing fluency, vocabulary, grammar, and topic relevancy.
This project implements a FastAPI application that transcribes spoken audio, analyzes its linguistic aspects (fluency, vocabulary, grammar), and assesses its relevancy to a given topic. The core processing is handled in the background, allowing for quick API responses.
The application processes transcribed audio and a given topic using several linguistic metrics:
lexicalrichness for MTLD and HD-D, nltk for word processing and commonness, textstat for readability.language_tool_python (an interface to LanguageTool).avsolatorio/GIST-Embedding-v0 model. This is a lightweight model known for its performance (ranked 31st on the MTEB Leaderboard as of May 2025) and efficiency, making it suitable for practical applications.While the current implementation uses a mock transcriber for demonstration, a real deployment would integrate with a powerful Automatic Speech Recognition (ASR) model like NVIDIA NeMo's Parakeet-TDT-0.6B-v2.
nvidia/parakeet-tdt-0.6b-v2This application is designed for Docker deployment to ensure all dependencies, including large models and NLTK data, are managed efficiently.
Prerequisites:
Project Setup:
main.py, download_models.py, download_nltk_data.py, requirements.txt) and the Dockerfile in the same directory.Prepare requirements.txt:
fastapi
uvicorn[standard]
python-multipart
sentence-transformers
scipy
scikit-learn
nltk
lexicalrichness
textstat
language-tool-python
aiofiles
nemo_toolkit[asr]
Dockerfile explicitly installs a CUDA-compatible PyTorch version before nemo_toolkit[asr].Create download_models.py:
The models come pre-loaded and downloaded when building the Docker, which contain the Transcription model and the embedding model
# download_models.py
import nemo.collections.asr as nemo_asr
from sentence_transformers import SentenceTransformer
import os
os.environ['HF_HOME'] = "/root/.cache/huggingface"
print("Downloading Sentence-BERT model: avsolatorio/GIST-Embedding-v0")
embed_model = SentenceTransformer('avsolatorio/GIST-Embedding-v0')
print("Embedding Model downloaded successfully!")
print("Downloading Transcription ASR Model: nvidia/parakeet-tdt-0.6b-v2")
asr_model = nemo_asr.models.ASRModel.from_pretrained(model_name="nvidia/parakeet-tdt-0.6b-v2")
print("Transcription Model downloaded successfully!")
Create download_nltk_data.py:
# download_nltk_data.py
import nltk
import os
nltk_data_dir = os.environ.get('NLTK_DATA', '/usr/local/nltk_data')
nltk.data.path.append(nltk_data_dir)
print(f"Downloading NLTK data to: {nltk_data_dir}")
def download_if_not_found(package_name):
try:
nltk.data.find(package_name)
print(f" {package_name} already found.")
except nltk.downloader.DownloadError:
print(f" Downloading {package_name}...")
nltk.download(package_name, download_dir=nltk_data_dir)
print(f" {package_name} downloaded.")
download_if_not_found('corpora/stopwords')
download_if_not_found('tokenizers/punkt')
download_if_not_found('corpora/wordnet')
download_if_not_found('corpora/brown')
print("NLTK data download script finished.")
Create Dockerfile: (Refer to the previous detailed Dockerfile provided, including multi-stage build, HF_HOME, NLTK_DATA, and the download_models.py and download_nltk_data.py steps.)
Build the Docker Image: Navigate to your project directory in the terminal and run:
docker build -t audio-analysis-app .
This step will download all necessary Python packages, the GIST embedding model, and NLTK data during the build process. This might take some time on the first run.
Run the Docker Container:
docker run -p 5000:5000 audio-analysis-app
This will start the FastAPI application inside a Docker container, accessible on your host machine at port 8000.
Access the API:
Open your web browser and go to http://127.0.0.1:5000/docs to interact with the API using Swagger UI.
POST /input:
unique_id to track the processing status and results.GET /results/{unique_id}:
unique_id.completed, or a 202 Accepted status if still processing.If you prefer to run locally for development and handle NLTK/model downloads manually:
pip install -r requirements.txt
import nltk
nltk.download('punkt')
nltk.download('stopwords')
nltk.download('wordnet')
nltk.download('brown')
SentenceTransformer will download the model automatically when it's first initialized in main.py (e.g., embedding_model = SentenceTransformer('avsolatorio/GIST-Embedding-v0')). This happens once.uvicorn main:app --reload
Oepnsource transcribing audio and analyzing fluency, vocabulary, grammar, and topic relevancy.
Python
0
1 commits
updated May 21, 2025
Opensource transcribing audio and analyzing fluency, vocabulary, grammar, and topic relevancy.
This project implements a FastAPI application that transcribes spoken audio, analyzes its linguistic aspects (fluency, vocabulary, grammar), and assesses its relevancy to a given topic. The core processing is handled in the background, allowing for quick API responses.
The application processes transcribed audio and a given topic using several linguistic metrics:
lexicalrichness for MTLD and HD-D, nltk for word processing and commonness, textstat for readability.language_tool_python (an interface to LanguageTool).avsolatorio/GIST-Embedding-v0 model. This is a lightweight model known for its performance (ranked 31st on the MTEB Leaderboard as of May 2025) and efficiency, making it suitable for practical applications.While the current implementation uses a mock transcriber for demonstration, a real deployment would integrate with a powerful Automatic Speech Recognition (ASR) model like NVIDIA NeMo's Parakeet-TDT-0.6B-v2.
nvidia/parakeet-tdt-0.6b-v2This application is designed for Docker deployment to ensure all dependencies, including large models and NLTK data, are managed efficiently.
Prerequisites:
Project Setup:
main.py, download_models.py, download_nltk_data.py, requirements.txt) and the Dockerfile in the same directory.Prepare requirements.txt:
fastapi
uvicorn[standard]
python-multipart
sentence-transformers
scipy
scikit-learn
nltk
lexicalrichness
textstat
language-tool-python
aiofiles
nemo_toolkit[asr]
Dockerfile explicitly installs a CUDA-compatible PyTorch version before nemo_toolkit[asr].Create download_models.py:
The models come pre-loaded and downloaded when building the Docker, which contain the Transcription model and the embedding model
# download_models.py
import nemo.collections.asr as nemo_asr
from sentence_transformers import SentenceTransformer
import os
os.environ['HF_HOME'] = "/root/.cache/huggingface"
print("Downloading Sentence-BERT model: avsolatorio/GIST-Embedding-v0")
embed_model = SentenceTransformer('avsolatorio/GIST-Embedding-v0')
print("Embedding Model downloaded successfully!")
print("Downloading Transcription ASR Model: nvidia/parakeet-tdt-0.6b-v2")
asr_model = nemo_asr.models.ASRModel.from_pretrained(model_name="nvidia/parakeet-tdt-0.6b-v2")
print("Transcription Model downloaded successfully!")
Create download_nltk_data.py:
# download_nltk_data.py
import nltk
import os
nltk_data_dir = os.environ.get('NLTK_DATA', '/usr/local/nltk_data')
nltk.data.path.append(nltk_data_dir)
print(f"Downloading NLTK data to: {nltk_data_dir}")
def download_if_not_found(package_name):
try:
nltk.data.find(package_name)
print(f" {package_name} already found.")
except nltk.downloader.DownloadError:
print(f" Downloading {package_name}...")
nltk.download(package_name, download_dir=nltk_data_dir)
print(f" {package_name} downloaded.")
download_if_not_found('corpora/stopwords')
download_if_not_found('tokenizers/punkt')
download_if_not_found('corpora/wordnet')
download_if_not_found('corpora/brown')
print("NLTK data download script finished.")
Create Dockerfile: (Refer to the previous detailed Dockerfile provided, including multi-stage build, HF_HOME, NLTK_DATA, and the download_models.py and download_nltk_data.py steps.)
Build the Docker Image: Navigate to your project directory in the terminal and run:
docker build -t audio-analysis-app .
This step will download all necessary Python packages, the GIST embedding model, and NLTK data during the build process. This might take some time on the first run.
Run the Docker Container:
docker run -p 5000:5000 audio-analysis-app
This will start the FastAPI application inside a Docker container, accessible on your host machine at port 8000.
Access the API:
Open your web browser and go to http://127.0.0.1:5000/docs to interact with the API using Swagger UI.
POST /input:
unique_id to track the processing status and results.GET /results/{unique_id}:
unique_id.completed, or a 202 Accepted status if still processing.If you prefer to run locally for development and handle NLTK/model downloads manually:
pip install -r requirements.txt
import nltk
nltk.download('punkt')
nltk.download('stopwords')
nltk.download('wordnet')
nltk.download('brown')
SentenceTransformer will download the model automatically when it's first initialized in main.py (e.g., embedding_model = SentenceTransformer('avsolatorio/GIST-Embedding-v0')). This happens once.uvicorn main:app --reload