Skip to main content

Mistral Voxtral plugin for the cjm-transcription-plugin-system library - provides local speech-to-text transcription through vLLM with configurable model selection and parameter control.

Project description

cjm-transcription-plugin-voxtral-vllm

Install

pip install cjm_transcription_plugin_voxtral_vllm

Project Structure

nbs/
└── plugin.ipynb # Plugin implementation for Mistral Voxtral transcription through vLLM server

Total: 1 notebook

Module Dependencies

graph LR
    plugin[plugin<br/>Voxtral VLLM Plugin]

No cross-module dependencies detected.

CLI Reference

No CLI commands found in this project.

Module Overview

Detailed documentation for each module in the project:

Voxtral VLLM Plugin (plugin.ipynb)

Plugin implementation for Mistral Voxtral transcription through vLLM server

Import

from cjm_transcription_plugin_voxtral_vllm.plugin import (
    VLLMServer,
    VoxtralVLLMPlugin
)

Functions

@patch
def supports_streaming(
    self: VoxtralVLLMPlugin
) -> bool
    "Check if this plugin supports streaming transcription."
@patch
def execute_stream(
    self: VoxtralVLLMPlugin,
    audio: Union[AudioData, str, Path],  # Audio data or path to audio file
    **kwargs  # Additional plugin-specific parameters
) -> Generator[str, None, TranscriptionResult]:  # Yields text chunks, returns final result
    """
    Stream transcription results chunk by chunk.
    
    Args:
        audio: Audio data or path to audio file
        **kwargs: Additional plugin-specific parameters
        
    Yields:
        str: Partial transcription text chunks as they become available
        
    Returns:
        TranscriptionResult: Final complete transcription with metadata
    """

Classes

class VLLMServer:
    def __init__(
        self,
        model: str = "mistralai/Voxtral-Mini-3B-2507",
        port: int = 8000,
        host: str = "0.0.0.0",
        gpu_memory_utilization: float = 0.85,
        log_level: str = "INFO",  # DEBUG, INFO, WARNING, ERROR
        capture_logs: bool = True,
        **kwargs
    )
    
    def __init__(
            self,
            model: str = "mistralai/Voxtral-Mini-3B-2507",
            port: int = 8000,
            host: str = "0.0.0.0",
            gpu_memory_utilization: float = 0.85,
            log_level: str = "INFO",  # DEBUG, INFO, WARNING, ERROR
            capture_logs: bool = True,
            **kwargs
        )
    
    def add_log_callback(self, callback: Callable[[str], None]):
            """Add a callback function that will be called for each log line.
            
            Args:
                callback: Function that takes a log line string as input
            """
            self.log_callbacks.append(callback)
        
        def _process_log_line(self, line: str)
        "Add a callback function that will be called for each log line.

Args:
    callback: Function that takes a log line string as input"
    
    def start(self, wait_for_ready: bool = True, timeout: int = 120, show_progress: bool = True):
            """Start the vLLM server.
            
            Args:
                wait_for_ready: Wait for server to be ready before returning
                timeout: Maximum time to wait for server to be ready
                show_progress: Show progress indicators during startup
            """
            if self.is_running()
        "Start the vLLM server.

Args:
    wait_for_ready: Wait for server to be ready before returning
    timeout: Maximum time to wait for server to be ready
    show_progress: Show progress indicators during startup"
    
    def stop(self):
            """Stop the vLLM server."""
            if self.process and self.process.poll() is None
        "Stop the vLLM server."
    
    def restart(self):
            """Restart the server."""
            self.stop()
            time.sleep(2)
            self.start()
        
        def is_running(self) -> bool
        "Restart the server."
    
    def is_running(self) -> bool
        "Check if server is running and responsive.

This method checks both if the process is alive and if the server
is actually responding to health checks."
    
    def get_recent_logs(self, n: int = 100) -> List[str]:
            """Get the most recent n log lines.
            
            Args:
                n: Number of recent log lines to retrieve
                
            Returns:
                List of recent log lines
            """
            logs = []
            while not self.log_queue.empty() and len(logs) < n
        "Get the most recent n log lines.

Args:
    n: Number of recent log lines to retrieve
    
Returns:
    List of recent log lines"
    
    def get_metrics_from_logs(self) -> dict:
            """Parse recent logs to extract performance metrics.
            
            Returns:
                Dictionary with metrics like throughput, GPU usage, etc.
            """
            metrics = {
                "prompt_throughput": 0.0,
        "Parse recent logs to extract performance metrics.

Returns:
    Dictionary with metrics like throughput, GPU usage, etc."
    
    def tail_logs(self, follow: bool = True, n: int = 10):
            """Tail the server logs (similar to tail -f).
            
            Args:
                follow: Continue displaying new logs as they arrive
                n: Number of initial lines to display
            """
            # Display recent logs
            recent = self.get_recent_logs(n)
            for line in recent
        "Tail the server logs (similar to tail -f).

Args:
    follow: Continue displaying new logs as they arrive
    n: Number of initial lines to display"
class VoxtralVLLMPlugin:
    def __init__(self):
        """Initialize the Voxtral VLLM plugin with default configuration."""
        self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
        self.config = {}
        self.server: Optional[VLLMServer] = None
    "Mistral Voxtral transcription plugin via vLLM server."
    
    def __init__(self):
            """Initialize the Voxtral VLLM plugin with default configuration."""
            self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
            self.config = {}
            self.server: Optional[VLLMServer] = None
        "Initialize the Voxtral VLLM plugin with default configuration."
    
    def name(
            self
        ) -> str:  # Returns the plugin name
        "Get the plugin name identifier."
    
    def version(
            self
        ) -> str:  # Returns the plugin version
        "Get the plugin version string."
    
    def supported_formats(
            self
        ) -> List[str]:  # Returns list of supported audio formats
        "Get the list of supported audio file formats."
    
    def get_config_schema(
        ) -> Dict[str, Any]:  # Returns the configuration schema dictionary
        "Return configuration schema for Voxtral VLLM."
    
    def get_current_config(
            self
        ) -> Dict[str, Any]:  # Returns the current configuration dictionary
        "Return current configuration."
    
    def initialize(
            self,
            config: Optional[Dict[str, Any]] = None  # Configuration dictionary to initialize the plugin
        ) -> None
        "Initialize the plugin with configuration."
    
    def execute(
            self,
            audio: Union[AudioData, str, Path],  # Audio data or path to audio file to transcribe
            **kwargs  # Additional arguments to override config
        ) -> TranscriptionResult:  # Returns transcription result with text and metadata
        "Transcribe audio using Voxtral via vLLM."
    
    def is_available(
            self
        ) -> bool:  # Returns True if vLLM and its dependencies are available
        "Check if vLLM and required dependencies are available."
    
    def cleanup(
            self
        ) -> None
        "Clean up resources."

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cjm_transcription_plugin_voxtral_vllm-0.0.3.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file cjm_transcription_plugin_voxtral_vllm-0.0.3.tar.gz.

File metadata

File hashes

Hashes for cjm_transcription_plugin_voxtral_vllm-0.0.3.tar.gz
Algorithm Hash digest
SHA256 762b3635aa005e75b7f214a2e213396c41573c1d725e9cf528036e537e3e33dc
MD5 ccb72ade5bec6eb8e3eada9425212000
BLAKE2b-256 00825aa263aec44355e784ec5a03b7b631ccfda47dfa6cb20e514d968a91c844

See more details on using hashes here.

File details

Details for the file cjm_transcription_plugin_voxtral_vllm-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for cjm_transcription_plugin_voxtral_vllm-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 7dc7ad2af26b6acd7677154ef439ad58a893855501bacede688467c14309a5ea
MD5 29ec3642d71b4874c1adcec7e77e39ad
BLAKE2b-256 92ae9f6dc49aa2bfa7c26de9599d1189d061995ab60fee519029cb4a26a033af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page