Skip to content

STTModule

The Speech-to-Text module enables voice dictation using the Web Speech API. Allows users to dictate text directly into the editor with real-time audio visualization.

Note: The Speech-to-Text module requires a browser that supports the Web Speech API (Chrome, Edge, Safari). If the API is not available, the module will display a disabled state with an appropriate message.

Options

option nametypedescriptiondefault valuepossible values
languagestringSpeech recognition language in BCP 47 format (e.g., 'en-US', 'fr-FR', 'es-ES')'en-EN'Any valid BCP 47 language code
continuousbooleanIf true, recognition automatically restarts after each pause. If false, user must manually restartfalsetrue, false
visualizerbooleanDisplay animated audio visualizer (equalizer with 14 columns) reflecting microphone input in real-timetruetrue, false
waveformColorstringGradient secondary color for the audio visualizer (top part of columns)'#4285f4'Any valid CSS color (hex, rgb, etc.)
histogramColorstringPrimary/accent color used for visualizer gradient, toolbar button when active, and listening label'#25D366'Any valid CSS color (hex, rgb, etc.)
debugbooleanEnable debug mode to display recognition logs and events in browser consolefalsetrue, false
buttonTitleStartstringTooltip text shown on microphone button hover when recognition is inactive'Start listening'Any string
buttonTitleStopstringTooltip text shown on microphone button hover when recognition is active'Stop listening'Any string
titleInactivestringLabel text displayed in the STT bar when recognition is inactive'Inactive'Any string
titleStartingstringLabel text displayed in the STT bar when recognition is initializing'Starting...'Any string
titleActivestringLabel text displayed in the STT bar during active listening'Listening...'Any string

Usage example

php
use Ehyiah\QuillJsBundle\Form\QuillType;
use Ehyiah\QuillJsBundle\DTO\Modules\STTModule;

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('content', QuillType::class, [
            'quill_options' => [
                QuillGroup::buildWithAllFields()
            ],
            'modules' => [
                new STTModule(
                    language: 'fr-FR',           // French language recognition
                    continuous: true,             // Auto-restart after pauses
                    visualizer: true,             // Show audio visualizer
                    waveformColor: '#4285f4',     // Blue gradient color
                    histogramColor: '#25D366',    // Green accent color
                    debug: false,                 // Disable debug logs
                    buttonTitleStart: 'Start voice dictation',
                    buttonTitleStop: 'Stop voice dictation',
                    titleInactive: 'Voice recognition inactive',
                    titleStarting: 'Initializing...',
                    titleActive: 'Listening to your voice...',
                ),
            ],
        ])
    ;
}