Skip to main content

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

Project description

cjm-transcription-plugin-voxtral-hf

Install

pip install cjm_transcription_plugin_voxtral_hf

Project Structure

nbs/
├── meta.ipynb   # Metadata introspection for the Voxtral HF plugin used by cjm-ctl to generate the registration manifest.
└── plugin.ipynb # Plugin implementation for Mistral Voxtral transcription through Hugging Face Transformers

Total: 2 notebooks

Module Dependencies

graph LR
    meta[meta<br/>Metadata]
    plugin[plugin<br/>Voxtral HF 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:

Metadata (meta.ipynb)

Metadata introspection for the Voxtral HF plugin used by cjm-ctl to generate the registration manifest.

Import

from cjm_transcription_plugin_voxtral_hf.meta import (
    get_plugin_metadata
)

Functions

def get_plugin_metadata() -> Dict[str, Any]: # Plugin metadata for manifest generation
    """Return metadata required to register this plugin with the PluginManager."""
    # Calculate default DB path relative to the environment
    base_path = os.path.dirname(os.path.dirname(sys.executable))
    data_dir = os.path.join(base_path, "data")
    db_path = os.path.join(data_dir, "voxtral_hf_transcriptions.db")
    
    # Ensure data directory exists
    os.makedirs(data_dir, exist_ok=True)

    return {
        "name": "cjm-transcription-plugin-voxtral-hf",
    "Return metadata required to register this plugin with the PluginManager."

Voxtral HF Plugin (plugin.ipynb)

Plugin implementation for Mistral Voxtral transcription through Hugging Face Transformers

Import

from cjm_transcription_plugin_voxtral_hf.plugin import (
    VoxtralHFPluginConfig,
    VoxtralHFPlugin
)

Functions

@patch
def supports_streaming(
    self:VoxtralHFPlugin
) -> bool:  # True if streaming is supported
    "Check if this plugin supports streaming transcription."
@patch
def execute_stream(
    self:VoxtralHFPlugin,
    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."

Classes

@dataclass
class VoxtralHFPluginConfig:
    "Configuration for Voxtral HF transcription plugin."
    
    model_id: str = field(...)
    device: str = field(...)
    dtype: str = field(...)
    language: Optional[str] = field(...)
    max_new_tokens: int = field(...)
    do_sample: bool = field(...)
    temperature: float = field(...)
    top_p: float = field(...)
    streaming: bool = field(...)
    trust_remote_code: bool = field(...)
    cache_dir: Optional[str] = field(...)
    compile_model: bool = field(...)
    load_in_8bit: bool = field(...)
    load_in_4bit: bool = field(...)
class VoxtralHFPlugin:
    def __init__(self):
        """Initialize the Voxtral HF plugin with default configuration."""
        self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
        self.config: VoxtralHFPluginConfig = None
    "Mistral Voxtral transcription plugin via Hugging Face Transformers."
    
    def __init__(self):
            """Initialize the Voxtral HF plugin with default configuration."""
            self.logger = logging.getLogger(f"{__name__}.{type(self).__name__}")
            self.config: VoxtralHFPluginConfig = None
        "Initialize the Voxtral HF plugin with default configuration."
    
    def name(self) -> str: # Plugin name identifier
            """Get the plugin name identifier."""
            return "voxtral_hf"
        
        @property
        def version(self) -> str: # Plugin version string
        "Get the plugin name identifier."
    
    def version(self) -> str: # Plugin version string
            """Get the plugin version string."""
            return "1.0.0"
        
        @property
        def supported_formats(self) -> List[str]: # List of supported audio formats
        "Get the plugin version string."
    
    def supported_formats(self) -> List[str]: # List of supported audio formats
            """Get the list of supported audio file formats."""
            return ["wav", "mp3", "flac", "m4a", "ogg", "webm", "mp4", "avi", "mov"]
    
        def get_current_config(self) -> Dict[str, Any]: # Current configuration as dictionary
        "Get the list of supported audio file formats."
    
    def get_current_config(self) -> Dict[str, Any]: # Current configuration as dictionary
            """Return current configuration state."""
            if not self.config
        "Return current configuration state."
    
    def get_config_schema(self) -> Dict[str, Any]: # JSON Schema for configuration
            """Return JSON Schema for UI generation."""
            return dataclass_to_jsonschema(VoxtralHFPluginConfig)
    
        @staticmethod
        def get_config_dataclass() -> VoxtralHFPluginConfig: # Configuration dataclass
        "Return JSON Schema for UI generation."
    
    def get_config_dataclass() -> VoxtralHFPluginConfig: # Configuration dataclass
            """Return dataclass describing the plugin's configuration options."""
            return VoxtralHFPluginConfig
        
        def initialize(
            self,
            config: Optional[Any] = None # Configuration dataclass, dict, or None
        ) -> None
        "Return dataclass describing the plugin's configuration options."
    
    def initialize(
            self,
            config: Optional[Any] = None # Configuration dataclass, dict, or None
        ) -> None
        "Initialize or re-configure the plugin (idempotent)."
    
    def execute(
            self,
            audio: Union[AudioData, str, Path], # Audio data or path to audio file to transcribe
            **kwargs # Additional arguments to override config
        ) -> TranscriptionResult: # Transcription result with text and metadata
        "Transcribe audio using Voxtral."
    
    def is_available(self) -> bool: # True if Voxtral and its dependencies are available
            """Check if Voxtral is available."""
            return VOXTRAL_AVAILABLE
        
        def cleanup(self) -> None
        "Check if Voxtral is available."
    
    def cleanup(self) -> None:
            """Clean up resources with aggressive memory management."""
            if self.model is None and self.processor is None
        "Clean up resources with aggressive memory management."

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_hf-0.0.9.tar.gz (16.5 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_hf-0.0.9.tar.gz.

File metadata

File hashes

Hashes for cjm_transcription_plugin_voxtral_hf-0.0.9.tar.gz
Algorithm Hash digest
SHA256 9a2488fbfb23c4acba55c0062efe6659327232546793908ba3ed4bd057270fa6
MD5 49294b9e9ed8c6be6185e301aa7028c8
BLAKE2b-256 f82f84f3aa82c513db539fb5aba5b4fe0a1d729afa275e8d070950e8f1c1b8a9

See more details on using hashes here.

File details

Details for the file cjm_transcription_plugin_voxtral_hf-0.0.9-py3-none-any.whl.

File metadata

File hashes

Hashes for cjm_transcription_plugin_voxtral_hf-0.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 d5e96949537048b67ff5f3ee72c43e33856ea798811f3fbb949bcdd467fc6b22
MD5 30debc6c2460dd7b4d05a0fd8a1690d1
BLAKE2b-256 1db65d300a56135dbf3578d9dd5ca2d9bad309e65bfa64775cec03a27e9ddb01

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