CoolFace
Apppublic

adityabanerjee/voxcpm2-studio

sourceHugging Faceapache-2.0updated 2mo agoView on Hugging Face
0likes
app.cpython-314.pyc58 linesDownload Raw Back to __pycache__
1+
2��wj�����^RIt]PPRR4]PPRR4^RIt^RIt^RIt^RIt	^RI3t4^RIt^RIH
t
RtRtR	t]
P"!]R5R6RR7t]3R
RlltR@RRllt]P*!]R7RARRll4tRt]P0!]P2P5RR7]R7;_uu_4t]P8!R4]P:!4;_uu_4]P<!^R7;_uu_4]P>!R^^RR7t ]P>!RRR 7t!]PD!R!R"R#R$.R%7t#]PH!R&R'R(7t%RRR4]P<!^R7;_uu_4]PD!R)R"R*7t&]PN!R+R7R,7;_uu_4]PP!R-R.RR/R0R17t)]PP!^^^8^R2R17t*]PV!^*^R3R47t,RRR4RRR4RRR4]%P[]] ]!]#])]*],.]&R5^R67]P\!R7.R8.R9..] .]&]R:R;R<7RRR4]/R=8Xd%]Pa^R>7PcR:R?7R#R# +'giEL);i +'giL�;i +'giL�;i +'giL�;i +'giL�;i)B�N�PYTORCH_CUDA_ALLOC_CONFzexpandable_segments:True�TOKENIZERS_PARALLELISM�false)�VoxCPMzopenbmb/VoxCPM2i�iF�cuda)�
load_denoiser�optimize�devicec�R�V^8�dQhR\R\R\\,/#)��text�	max_chars�return)�str�int�list)�formats"�hf_space_voxcpm2/app.py�__annotate__rs%����S��S��t�C�y��c��^RIpVPRVP44p.pRpVFvpVP4pV'gKV'd=\V4\V4,^,V8�dVP	V4TpKaVRV2P4pKx	V'dVP	V4V#)zASplit long narration at sentence boundaries for stable synthesis.Nu(?<=[.!?。!?])\s*�� )�re�split�strip�len�append)r
rr�	sentences�chunks�current�sentences&&     r�9split_textr#s���
����2�D�J�J�L�A�I��F��G����>�>�#�����s�7�|�c�(�m�3�a�7�)�C��M�M�'�"��G� �	��8�*�-�3�3�5�G����
�
�g���Mr�@c�z�V^8�dQhR\R\R\R,R\R\R\R\/#�	rr
�voice_description�reference_audioN�	cfg_value�inference_timesteps�seedr�r�floatr)rs"rrr1s[��^�^�10
�^��^��4�Z�^��	^�11�^��
^�	�^rc
��\^�\^-\^#\T;'gR4R,,\V4^,,444#)zBEstimate ZeroGPU reservation from text length and diffusion steps.rg���Q��?)�min�maxrr)r
r'r(r)r*r+�args�kwargss&&&&&&*,r�estimate_gpu_secondsr31sB���s�C��C��S�����_�t�%;� ;�c�BU�>V�YZ�>Z� Z�[�\�]�]r)�duration�,A warm, confident narrator with clear pacingc�z�V^8�dQhR\R\R\R,R\R\R\R\/#r&r,)rs"rrr@sR��?�?�12
�?��?��4�Z�?��	?�13�?��
?�	�?rc��RPT;'gRP44pV'g\P!R4h\	V4\148�d\P!R\15R24h\
V4p\V4p\V4pRTu;8:dR8:gM\P!R4h^Tu;8:d^8:gM\P!R	4h\V4p.p\V4F�wr�T16pV'g-VP4'dR17VP4RV182p\PTT;'gRVVR
RR
WY,R7pVP\P!V\P R74K�	V'g\P!R4h\P"!\\P$P&R,4\P R7p
.p\V4F/wr�V	'dVPV
4VPV4K1	\P(!V4p\*P,!RRR7pVP/4\0P2!VP4V\P$P&RR7VP4#)a�Generate 48 kHz speech with VoxCPM2.19 20Args:21    text: Narration to synthesize in any VoxCPM2-supported language.22    voice_description: Natural-language voice style used without reference audio.23    reference_audio: Optional short WAV recording for voice cloning.24    cfg_value: Guidance strength, normally between 1.5 and 3.0.25    inference_timesteps: Diffusion steps; higher can improve quality but costs time.26    seed: Reproducibility seed.27rrzEnter text to synthesize.zText is limited to z characters per request.��?�@z CFG must be between 1.0 and 4.0.z)Inference steps must be between 4 and 20.�(�)NTF)r
�reference_wav_pathr)r*�	normalize�denoise�
retry_badcaser+)�dtypezVoxCPM2 did not produce audio.g28ףp=29�?z.wav)�delete�suffix�PCM_16)�subtype)�joinr�gr�Errorr�MAX_TEXT_CHARSr-rr#�	enumerater�model�generater�np�asarray�float32�zeros�	tts_model�sample_rate�concatenate�tempfile�NamedTemporaryFile�close�sf�write�name)r
r'r(r)r*r+�cleanedr �	generated�index�chunk�
designed_text�wav�pause�pieces�full_wav�outputs&&&&&&           r�30synthesizerc?s ��&�h�h��31�32��)�)�+�,�G���h�h�2�3�3�33�7�|�n�$��h�h�,�^�,<�<T�U�V�V��i� �I��1�2���t�9�D��)�"�s�"��h�h�9�:�:��#�)�r�)��h�h�B�C�C�
��
 �F�"$�I�!�&�)����
��#4�#:�#:�#<�#<�� 1� 7� 7� 9�:�!�E�7�C�M��n�n��.�6�6�$�� 3�������	34��	������C�r�z�z�:�;�*� ��h�h�7�8�8��H�H�S����4�4�t�;�<�B�J�J�O�E�!�F��	�*�35����M�M�%� ��
�
�c��+��~�~�f�%�H�
�
(�
(��f�
E�F�36�L�L�N��H�H�V�[�[�(�E�O�O�$?�$?��R��;�;�rz�37.gradio-container { max-width: 1040px !important; margin: auto !important; }38.hero { text-align: center; padding: 1rem 0 .25rem; }39.hero h1 { font-size: 2.3rem; margin-bottom: .35rem; }40.dark .gradio-container { color: var(--body-text-color); }41�indigo)�primary_hue)�theme�cssu�<div class='hero'><h1>🎙️ VoxCPM2 Studio</h1><p>Multilingual 48 kHz speech, voice design, and optional voice cloning.</p></div>)�scale�	NarrationuKType narration in English, Hindi, Chinese, or another supported language…)�label�lines�	max_lines�placeholderzVoice design)rj�valuezReference voice (optional)�filepath�upload�42microphone)rj�type�sourceszGenerate speech�primary)�variantzGenerated 48 kHz speech)rjrrzAdvanced settings)�openr8r9g�������?zCFG guidance)rn�steprjzInference steps�Seed)rn�	precisionrj�tts)�fn�inputs�outputs�api_name�concurrency_limitz[VoxCPM2 brings multilingual speech and expressive voice design to open-source applications.u�नमस्ते! यह एक स्वाभाविक और स्पष्ट हिंदी आवाज़ का उदाहरण है।u-你好,欢迎体验多语言语音合成。T�lazy)�examplesr|r}r{�cache_examples�43cache_mode�__main__)�default_concurrency_limit)�44mcp_server)rNr$�45�*)r5Nr$r�r�)2�os�environ�46setdefault�spaces�gradiorF�numpyrL�	soundfilerVrS�torch�voxcpmr�MODEL_IDrH�MAX_CHUNK_CHARS�from_pretrainedrJr#r3�GPUrc�CSS�Blocks�themes�Soft�demo�HTML�Row�Column�Textboxr
r'�Audior(�ButtonrK�output_audio�	Accordion�Slider�cfg�steps�Numberr+�click�Examples�__name__�queue�launch�rr�<module>r�s���	��47�48���/�1K�L��49�50���.��8�
�������������	�����
��		��,;��*^����)�*�?�+�?�D���Y�Y�R�Y�Y�^�^��^�9�s�C�C�t��G�G�	]��51�����
�Y�Y�Q�
�
��:�:�!���i�	�D�!#�52�53�$�D�!��!�h�h�2��h�Xd�Me��O��y�y�!2�I�F�H� ��Y�Y�Q�
�
��8�8�*C�*�U�L����1��>�>��i�i��S��#�^�T���	�	�!�R�r��AR�S���y�y�r�Q�f�E��?� �!54�.
�N�N���'��#�u�d�K�������K�K�
j�k�k�
l�
<�=�55�56�v������GD�b�z���J�J��J�+�2�2�d�2�C��W �
�
��"?�>�� �
��!57���D�C�so�,K)�58K	�&AJ
�<#K	�1K
�AJ0�K
�K	�$AK)�J-�'	K	�0K�;K
�K�K	�K&
�!K)�)K9