From d3cc88722c9d86d91a5e200e97b4d46154e46161 Mon Sep 17 00:00:00 2001 From: gluttony-10 <52977964+gluttony-10@users.noreply.github.com> Date: Tue, 21 Apr 2026 07:07:24 +0000 Subject: [PATCH] feat: enhance control text processing in VoxCPMDemo Added regex to strip parentheses from control instructions in the text synthesis method to ensure compatibility with the expected prompt format. This change improves the robustness of the input handling. --- app.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app.py b/app.py index ac008bc..dba6fe3 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,5 @@ import os +import re import sys import logging import numpy as np @@ -290,6 +291,9 @@ class VoxCPMDemo: raise ValueError("Please input text to synthesize.") control = (control_instruction or "").strip() + # Strip any parentheses (half-width/full-width) from control text to avoid + # breaking the "(control)text" prompt format expected by the model. + control = re.sub(r"[()()]", "", control).strip() final_text = f"({control}){text}" if control else text audio_path = reference_wav_path_input if reference_wav_path_input else None