Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/KoljaB/RealtimeVoiceChat
/ functions
Functions
152 in github.com/KoljaB/RealtimeVoiceChat
⨍
Functions
152
◇
Types & classes
25
↳
Endpoints
2
↓ 49 callers
Method
apply
Start a formatting chain for the given text. Usage: print(Colors.apply("Hello").red.bold)
code/colors.py:79
↓ 24 callers
Method
calculate_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 callers
Function
ends_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 callers
Function
renderMessages
()
code/static/app.js:187
↓ 5 callers
Method
generate
Generates text using the configured backend, yielding tokens as a stream. Handles lazy initialization (including potential `ollama p
code/llm_module.py:595
↓ 5 callers
Method
is_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 callers
Function
log_status
()
code/server.py:407
↓ 4 callers
Method
_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 callers
Method
_get_recorder_param
Internal helper to get a parameter from the recorder instance, abstracting client/server differences. Args: para
code/transcribe.py:178
↓ 4 callers
Method
_set_recorder_param
Internal helper to set a parameter on the recorder instance, abstracting client/server differences. Args: param_
code/transcribe.py:200
↓ 4 callers
Method
cancel_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 callers
Method
on_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 callers
Method
_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 callers
Method
_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 callers
Method
abort_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 callers
Function
cleanupAudio
()
code/static/app.js:168
↓ 3 callers
Method
preprocess_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 callers
Method
reset
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 callers
Method
set_silence
Updates the internal silence state and triggers the silence_active_callback. Args: silence_active: The new silence state
code/transcribe.py:563
↓ 2 callers
Method
_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 callers
Function
_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 callers
Function
_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 callers
Method
_is_recorder_recording
Internal helper to check if the recorder is currently recording, abstracting client/server differences. Returns:
code/transcribe.py:218
↓ 2 callers
Method
_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 callers
Method
_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 callers
Method
abort_generation
Signals the underlying transcriber to abort any ongoing generation process.
code/audio_in.py:71
↓ 2 callers
Method
are_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 callers
Method
check_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 callers
Method
detect_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 callers
Function
escapeHtml
(str)
code/static/app.js:265
↓ 2 callers
Function
flushBatch
()
code/static/app.js:55
↓ 2 callers
Function
flushRemainder
()
code/static/app.js:67
↓ 2 callers
Function
format_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 callers
Method
get_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 callers
Method
is_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 callers
Method
measure_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 callers
Method
on_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 callers
Method
prewarm
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 callers
Method
reset_state
Resets connection-specific state flags and variables to their initial values.
code/server.py:568
↓ 2 callers
Method
send_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 callers
Function
strip_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 callers
Method
update_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 callers
Method
_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 callers
Method
_normalize_text
Internal helper to normalize text for comparison purposes. Converts to lowercase, removes non-alphanumeric characters (except spaces)
code/transcribe.py:427
↓ 1 callers
Function
_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 callers
Function
_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 callers
Method
_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 callers
Method
_setup_callbacks
Sets up internal callbacks for the TranscriptionProcessor instance.
code/audio_in.py:76
↓ 1 callers
Method
_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 callers
Method
_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 callers
Method
abort_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 callers
Function
base64ToInt16Array
(b64)
code/static/app.js:82
↓ 1 callers
Method
calculate_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 callers
Method
clean_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 callers
Function
create_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 callers
Function
ensure_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 callers
Method
feed_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 callers
Function
find_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 callers
Method
get_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 callers
Method
get_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 callers
Method
get_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 callers
Method
get_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 callers
Method
get_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 callers
Function
handleJSONMessage
({ type, content })
code/static/app.js:210
↓ 1 callers
Function
initAudioContext
()
code/static/app.js:76
↓ 1 callers
Function
initBatch
()
code/static/app.js:46
↓ 1 callers
Function
interpolate_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 callers
Method
on_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 callers
Method
on_tts_allowed_to_synthesize
Callback invoked when the system determines TTS synthesis can proceed.
code/server.py:628
↓ 1 callers
Function
parse_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 callers
Method
prepare_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 callers
Function
preprocess_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 callers
Method
process_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 callers
Method
process_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 callers
Method
process_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 callers
Function
process_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 callers
Method
process_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 callers
Function
send_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 callers
Function
send_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 callers
Function
setupTTSPlayback
()
code/static/app.js:138
↓ 1 callers
Function
setup_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 callers
Method
shutdown
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 callers
Function
startRawPcmCapture
()
code/static/app.js:92
↓ 1 callers
Method
suggest_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 callers
Method
synthesize
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 callers
Method
synthesize_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