MCPcopy Create free account

hub / github.com/KoljaB/RealtimeVoiceChat / functions

Functions152 in github.com/KoljaB/RealtimeVoiceChat

↓ 49 callersMethodapply
Start a formatting chain for the given text. Usage: print(Colors.apply("Hello").red.bold)
code/colors.py:79
↓ 24 callersMethodcalculate_similarity
Calculates the similarity ratio between two texts based on the configuration. Normalizes both input texts, then calculates similarit
code/text_similarity.py:111
↓ 6 callersFunctionends_with_string
Checks if a string ends with a specific substring, allowing for one trailing character. Useful for checking punctuation even if there's a tr
code/turndetect.py:23
↓ 6 callersFunctionrenderMessages
()
code/static/app.js:187
↓ 5 callersMethodgenerate
Generates text using the configured backend, yielding tokens as a stream. Handles lazy initialization (including potential `ollama p
code/llm_module.py:595
↓ 5 callersMethodis_valid_gen
Checks if there is a currently running generation that has not started aborting. Returns: True if `running_generation` e
code/speech_pipeline_manager.py:219
↓ 5 callersFunctionlog_status
()
code/server.py:407
↓ 4 callersMethod_get_last_n_words_text
Extracts the last `n_words` from a normalized text string. Splits the text by spaces and joins the last `n_words` back together.
code/text_similarity.py:92
↓ 4 callersMethod_get_recorder_param
Internal helper to get a parameter from the recorder instance, abstracting client/server differences. Args: para
code/transcribe.py:178
↓ 4 callersMethod_set_recorder_param
Internal helper to set a parameter on the recorder instance, abstracting client/server differences. Args: param_
code/transcribe.py:200
↓ 4 callersMethodcancel_generation
Requests cancellation of active generation streams. If `request_id` is provided, cancels that specific stream. If `request_i
code/llm_module.py:349
↓ 4 callersMethodon_partial_assistant_text
Callback invoked when a partial text result from the assistant (LLM) is available. Updates the internal assistant answer state and s
code/server.py:753
↓ 3 callersMethod_lazy_initialize_clients
Initializes backend clients or checks connections on first use (thread-safe). Creates the appropriate HTTP client (OpenAI SDK or req
code/llm_module.py:267
↓ 3 callersMethod_register_request
Registers an active generation stream for cancellation tracking (thread-safe). Stores the request ID, type, stream object, and start
code/llm_module.py:431
↓ 3 callersMethodabort_generation
Public method to initiate the abortion of the current speech generation. Calls the internal `process_abort_generation` method to han
code/speech_pipeline_manager.py:1011
↓ 3 callersFunctioncleanupAudio
()
code/static/app.js:168
↓ 3 callersMethodpreprocess_chunk
Preprocesses a text chunk before sending it to the TTS engine. Replaces specific characters (em-dashes, quotes, ellipsis) with simpl
code/speech_pipeline_manager.py:288
↓ 3 callersMethodreset
Resets the internal state of the TurnDetection instance. Clears the text history deques, the model prediction cache, and resets the
code/turndetect.py:519
↓ 3 callersMethodset_silence
Updates the internal silence state and triggers the silence_active_callback. Args: silence_active: The new silence state
code/transcribe.py:563
↓ 2 callersMethod_cancel_single_request_unsafe
Internal helper to handle cancellation for a single request (thread-unsafe). Removes the request data from the `_active_requests` di
code/llm_module.py:387
↓ 2 callersFunction_check_ollama_connection
Performs a quick HTTP GET request to check connectivity with an Ollama server. Uses the provided requests Session and base URL to attempt a
code/llm_module.py:103
↓ 2 callersFunction_create_openai_client
Creates and configures an OpenAI API client instance. Handles API key logic (using a placeholder if none provided for local models) and
code/llm_module.py:66
↓ 2 callersMethod_is_recorder_recording
Internal helper to check if the recorder is currently recording, abstracting client/server differences. Returns:
code/transcribe.py:218
↓ 2 callersMethod_normalize_text
Prepares text for comparison by simplifying it. Converts the input text to lowercase, removes all characters that are not al
code/text_similarity.py:67
↓ 2 callersMethod_yield_openai_chunks
Iterates over an OpenAI/LMStudio stream, yielding content chunks. Handles extracting content from stream chunks and checks for cance
code/llm_module.py:749
↓ 2 callersMethodabort_generation
Signals the underlying transcriber to abort any ongoing generation process.
code/audio_in.py:71
↓ 2 callersMethodare_texts_similar
Determines if two texts meet the similarity threshold. Calculates the similarity between `text1` and `text2` using the configured
code/text_similarity.py:182
↓ 2 callersMethodcheck_abort
Checks if the current generation should be aborted based on new input text. Compares the provided text (`txt`) with the text of the
code/speech_pipeline_manager.py:442
↓ 2 callersMethoddetect_potential_sentence_end
Detects potential sentence endings based on ending punctuation and timing stability. Checks if the provided text ends with sentence-
code/transcribe.py:469
↓ 2 callersFunctionescapeHtml
(str)
code/static/app.js:265
↓ 2 callersFunctionflushBatch
()
code/static/app.js:55
↓ 2 callersFunctionflushRemainder
()
code/static/app.js:67
↓ 2 callersFunctionformat_timestamp_ns
Formats a nanosecond timestamp into a human-readable HH:MM:SS.fff string. Args: timestamp_ns: The timestamp in nanoseconds since the
code/server.py:202
↓ 2 callersMethodget_suggested_whisper_pause
Determines a base pause duration based on the text's ending punctuation. Checks for specific ending patterns ('...', '.', '!', '?')
code/turndetect.py:376
↓ 2 callersMethodis_basically_the_same
Checks if two text strings are highly similar, focusing on the ending words. Uses the internal TextSimilarity instance. Args
code/transcribe.py:446
↓ 2 callersMethodmeasure_inference_time
Measures the time taken to generate a target number of initial tokens. Uses a fixed, predefined prompt designed to elicit a somewhat
code/llm_module.py:963
↓ 2 callersMethodon_first_audio_chunk_synthesize
Callback method invoked by AudioProcessor when the first TTS audio chunk is ready. Sets the `quick_answer_first_chunk_ready` flag on
code/speech_pipeline_manager.py:277
↓ 2 callersMethodprewarm
Attempts to "prewarm" the LLM connection and potentially load the model. Runs a simple, short generation task ("Respond with only th
code/llm_module.py:485
↓ 2 callersMethodreset_state
Resets connection-specific state flags and variables to their initial values.
code/server.py:568
↓ 2 callersMethodsend_final_assistant_answer
Sends the final (or best available) assistant answer to the client. Constructs the full answer from quick and final parts if availab
code/server.py:816
↓ 2 callersFunctionstrip_ending_punctuation
Removes trailing punctuation marks defined in `sentence_end_marks`. Removes trailing whitespace first, then iteratively removes any characte
code/turndetect.py:68
↓ 2 callersMethodupdate_settings
Adjusts dynamic pause parameters based on a speed factor. Linearly interpolates between 'fast' (speed_factor=0.0) and 'very_slow'
code/turndetect.py:255
↓ 1 callersMethod_create_recorder
Internal helper to initialize the RealtimeSTT recorder instance (either local or client) with the specified configuration and callbac
code/transcribe.py:653
↓ 1 callersMethod_normalize_text
Internal helper to normalize text for comparison purposes. Converts to lowercase, removes non-alphanumeric characters (except spaces)
code/transcribe.py:427
↓ 1 callersFunction_reset_interrupt_flag_async
Resets the microphone interruption flag after a delay (async version). Waits for 1 second, then checks if the AudioInputProcessor is still m
code/server.py:355
↓ 1 callersFunction_run_ollama_ps
Attempts to run the 'ollama ps' command via subprocess. This is used as a potential fallback diagnostic/recovery step if the initial HTT
code/llm_module.py:149
↓ 1 callersMethod_run_transcription_loop
Continuously runs the transcription loop in a background asyncio task. It repeatedly calls the underlying `transcribe_loop`. If `tra
code/audio_in.py:87
↓ 1 callersMethod_setup_callbacks
Sets up internal callbacks for the TranscriptionProcessor instance.
code/audio_in.py:76
↓ 1 callersMethod_start_silence_monitor
Starts a background thread to monitor silence duration and trigger events like potential sentence end detection, TTS synthesis allowa
code/transcribe.py:235
↓ 1 callersMethod_yield_ollama_chunks
Iterates over an Ollama HTTP response stream, decoding JSON lines and yielding content. Handles reading bytes, decoding UTF-8, parsi
code/llm_module.py:818
↓ 1 callersMethodabort_generations
Triggers the abortion of any ongoing speech generation process. Logs the reason and calls the SpeechPipelineManager's abort method.
code/server.py:728
↓ 1 callersFunctionbase64ToInt16Array
(b64)
code/static/app.js:82
↓ 1 callersMethodcalculate_waiting_time
Adds a text segment to the processing queue for waiting time calculation. This is the entry point for feeding text into the turn det
code/turndetect.py:504
↓ 1 callersMethodclean_quick_answer
Removes specific leading patterns (like '<think>', newlines, spaces) from text. Intended for cleaning the initial output of the LLM,
code/speech_pipeline_manager.py:303
↓ 1 callersFunctioncreate_directory
Creates a directory at the specified path if it doesn't already exist. Args: path: The directory path to create.
code/audio_module.py:32
↓ 1 callersFunctionensure_lasinya_models
Ensures the Coqui XTTS Lasinya model files are present locally. Checks for required model files (config.json, vocab.json, etc.) within t
code/audio_module.py:42
↓ 1 callersMethodfeed_audio
Feeds an audio chunk to the underlying recorder instance for processing. Args: chunk: A bytes object containing the raw
code/transcribe.py:781
↓ 1 callersFunctionfind_matching_texts
Finds recent consecutive entries with the same stripped text. Iterates backwards through the deque of (original_text, stripped_text) tuples.
code/turndetect.py:88
↓ 1 callersMethodget_audio_copy
Copies the current audio buffer from the recorder's frames. Retrieves the raw audio frames, concatenates them, converts to a float32
code/transcribe.py:601
↓ 1 callersMethodget_base64_chunk
Processes an incoming audio chunk, upsamples it, and returns the relevant segment as Base64. Converts the raw PCM bytes (assumed 16-
code/upsample_overlap.py:26
↓ 1 callersMethodget_completion_probability
Calculates the probability that the given sentence is complete using the ML model. Uses an internal LRU cache (`_completion_probabil
code/turndetect.py:322
↓ 1 callersMethodget_context
Finds the shortest valid context at the beginning of the input text. Scans the text `txt` from the beginning up to `max_len` charact
code/text_context.py:33
↓ 1 callersMethodget_last_audio_copy
Returns the last successfully captured audio buffer as a float32 NumPy array. Attempts to get the current audio buffer first. If suc
code/transcribe.py:576
↓ 1 callersFunctionhandleJSONMessage
({ type, content })
code/static/app.js:210
↓ 1 callersFunctioninitAudioContext
()
code/static/app.js:76
↓ 1 callersFunctioninitBatch
()
code/static/app.js:46
↓ 1 callersFunctioninterpolate_detection
Linearly interpolates a value based on probability using predefined anchor points. Maps an input probability `prob` (clamped between 0.0 and
code/turndetect.py:129
↓ 1 callersMethodon_new_waiting_time
Callback handler for when TurnDetection calculates a new waiting time. Updates the recorder's post_speech_silence_duration parameter.
code/transcribe.py:320
↓ 1 callersMethodon_tts_allowed_to_synthesize
Callback invoked when the system determines TTS synthesis can proceed.
code/server.py:628
↓ 1 callersFunctionparse_json_message
Safely parses a JSON string into a dictionary. Logs a warning if the JSON is invalid and returns an empty dictionary. Args: tex
code/server.py:184
↓ 1 callersMethodprepare_generation
Public method to request the preparation of a new speech generation. Queues a 'prepare' action with the provided text onto the `requ
code/speech_pipeline_manager.py:986
↓ 1 callersFunctionpreprocess_text
Cleans and normalizes the beginning of a text string. Applies the following steps: 1. Removes leading whitespace. 2. Removes leading
code/turndetect.py:43
↓ 1 callersMethodprocess_abort_generation
Handles the core logic of aborting the current generation. Synchronized using `abort_lock`. If a `running_generation` exists:
code/speech_pipeline_manager.py:834
↓ 1 callersMethodprocess_audio_chunk
Converts raw audio bytes (int16) to a 16kHz 16-bit PCM numpy array. The audio is converted to float32 for accurate resampling and th
code/audio_in.py:120
↓ 1 callersMethodprocess_chunk_queue
Continuously processes audio chunks received from an asyncio Queue. Retrieves audio data, processes it using `process_audio_chunk`,
code/audio_in.py:153
↓ 1 callersFunctionprocess_incoming_data
Receives messages via WebSocket, processes audio and text messages. Handles binary audio chunks, extracting metadata (timestamp, flags) and
code/server.py:232
↓ 1 callersMethodprocess_prepare_generation
Handles the 'prepare' action: initiates a new text-to-speech generation. 1. Calls `check_abort` to potentially stop and clean up any
code/speech_pipeline_manager.py:773
↓ 1 callersFunctionsend_text_messages
Continuously sends text messages from a queue to the client via WebSocket. Waits for messages on the `message_queue`, formats them as JSON,
code/server.py:327
↓ 1 callersFunctionsend_tts_chunks
Continuously sends TTS audio chunks from the SpeechPipelineManager to the client. Monitors the state of the current speech generation (if an
code/server.py:376
↓ 1 callersFunctionsetupTTSPlayback
()
code/static/app.js:138
↓ 1 callersFunctionsetup_logging
Configures the root logger for console output with a custom format and level. Sets up a `StreamHandler` for the root logger if no handlers a
code/logsetup.py:38
↓ 1 callersMethodshutdown
Initiates shutdown procedures for the audio processor and transcriber. Signals the transcriber to shut down and cancels the backgrou
code/audio_in.py:219
↓ 1 callersFunctionstartRawPcmCapture
()
code/static/app.js:92
↓ 1 callersMethodsuggest_time
Invokes the `on_new_waiting_time` callback with the suggested pause duration. Only triggers the callback if the new suggested time i
code/turndetect.py:299
↓ 1 callersMethodsynthesize
Synthesizes audio from a complete text string and puts chunks into a queue. Feeds the entire text string to the TTS engine. As audio
code/audio_module.py:229
↓ 1 callersMethodsynthesize_generator
Synthesizes audio from a generator yielding text chunks and puts audio into a queue. Feeds text chunks yielded by the generator to t
code/audio_module.py:409
Method__enter__
Enters the context, starts generation, and returns the token generator. Calls the LLM's `generate` method and registers the request.
code/llm_module.py:1121
Method__exit__
Exits the context, ensuring the generation stream is cancelled and closed. Calls `llm.cancel_generation` to remove tracking and atte
code/llm_module.py:1155
Method__getattr__
(self, name: str)
code/colors.py:65
Method__init__
Initializes the AudioProcessor with a specific TTS engine. Sets up the chosen engine (Coqui, Kokoro, Orpheus), downloads Coqui model
code/audio_module.py:79
Method__init__
Initializes the TextSimilarity comparator. Args: similarity_threshold: The ratio threshold for `are_texts_similar`.
code/text_similarity.py:28
Method__init__
Initializes the LLM interface for a specific backend and model. Args: backend: The name of the LLM backend to use (e.g.,
code/llm_module.py:195
Method__init__
Initializes the generation context. Args: llm: The LLM instance to use for generation. prompt: The user's in
code/llm_module.py:1094
Method__init__
Initializes the TextContext processor. Sets up the characters used to determine valid context boundaries. Args:
code/text_context.py:15
Method__init__
Initializes the TranscriptionProcessor. Args: source_language: Language code for transcription (e.g., "en").
code/transcribe.py:95
Method__init__
Initializes the UpsampleOverlap processor. Sets up the internal state required for tracking previous audio chunks and their
code/upsample_overlap.py:16
Method__init__
(self, text: str)
code/colors.py:61
Method__init__
Initializes the AudioInputProcessor. Args: language: Target language code for transcription (e.g., "en"). is
code/audio_in.py:23
Method__init__
Initializes the TranscriptionCallbacks instance for a WebSocket connection. Args: app: The FastAPI application instance
code/server.py:527
Method__init__
Initializes the TurnDetection instance. Loads the sentence classification model and tokenizer, sets up internal state (deque
code/turndetect.py:180
next →1–100 of 152, ranked by callers