Files
soprano_to_rvc/__pycache__/unified_soprano_rvc.cpython-310.pyc

96 lines
12 KiB
Plaintext
Raw Normal View History

o
Inei5=<00>@sLdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
m Z ddl m Z mZddlmZddlmZmZe je jdd<08>e <09><16><00>e j<15>e<08>d <09>d
ejd <d ejd <ej<1A>dee e<1D>jd<00><01>ddlZ ddl!Z"ddl#m$Z%ddl&Z&ddl'm(Z(e Gdd<12>d<12><02>Z)Gdd<14>d<14>Z*dd<16>Z+e,dkr<>e+<2B>dSdS)zt
Unified Soprano TTS + RVC Pipeline
Combines soprano_to_virtual_sink.py and headless_rvc.py into a single interface
<EFBFBD>N)<01>Path)<02> dataclass<73>asdict)<01>Optional)<02>redirect_stdout<75>redirect_stderrz%(levelname)s: %(message)s)<02>level<65>format<61>ignore<72>3ZTF_CPP_MIN_LOG_LEVEL<45>1ZMIOPEN_LOG_LEVEL<45>soprano)<01>signal)<01>
SopranoTTSc@s.eZdZUdZeed<eed<dZeed<dZe ed<dZ
e ed <d
Z eed <d Z e ed <dZ e ed<dZeed<dZeed<dZeeed<dZeed<dZeed<d Ze ed<dZe ed<dZe ed<dZeed <d!Zeed"<d!Zeed#<d$Zeed%<d&Ze ed'<ed(ed)dfd*d+<2B><04>Zd(efd,d-<2D>ZdS).<2E> RVCConfigzRVC configuration parameters<72>pth<74>indexr<00>pitch<63><00>formant<6E><00>?<3F>
index_rate<EFBFBD><00> filter_radius<75><00>?<3F> rms_mix_rate<74><1F><>Q<EFBFBD><1E>?<3F>protect<63>rmvpe<70>f0method<6F> soprano_rvc<76> input_deviceN<65> output_device逻<00>
samplerate<EFBFBD><00>channels<6C>
block_timeg{<14>G<EFBFBD>z<EFBFBD>?<3F>crossfade_timeg@<40>
extra_time<EFBFBD><00>n_cpuF<75>I_noise_reduce<63>O_noise_reduceT<65>use_pv<70>N<><4E> threshold<6C> config_path<74>returncCsBt|d<01><02> }t<01>|<02>}Wd<00>n1swY|di|<03><01>S)z!Load configuration from JSON file<6C>rN<72>)<03>open<65>json<6F>load)<04>clsr1<00>f<>datar4r4<00>0/data/NVMe/AI/soprano2RVC/unified_soprano_rvc.py<70> from_fileGs  <1C>zRVCConfig.from_filecCsDt|d<01><02>}tjt|<00>|dd<03>Wd<00>dS1swYdS)zSave configuration to JSON file<6C>wr%)<01>indentN)r5r6<00>dumpr)<03>selfr1r9r4r4r;<00>to_fileNs "<22>zRVCConfig.to_file) <20>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__<5F>str<74>__annotations__r<00>intr<00>floatrrrrrr!r"rr$r&r'r(r)r+r,<00>boolr-r.r0<00> classmethodr<rAr4r4r4r;r.s4
                  rc@sbeZdZdZddedefdd<06>Zdd<08>Zd d
<EFBFBD>Zd d <0C>Z d d<0E>Z
defdd<11>Z dd<13>Z dd<15>Z dS)<18>UnifiedPipelinez"Unified Soprano TTS + RVC pipeline<6E>soprano_to_rvc<76>
rvc_config<EFBFBD>virtual_sink_namecCs:||_||_d|_d|_d|_d|_d|_d|_d|_dS)NFi}r#) rNrOr Z rvc_process<73>
rvc_thread<EFBFBD>soprano_stream<61>running<6E>soprano_sample_rate<74>virtual_sink_sample_rate)r@rNrOr4r4r;<00>__init__Ws
zUnifiedPipeline.__init__c Cs<>td<01>tjgd<02>ddd<04>}|j|jvr7td|j<03><00><02>t<01>dddd |j<03><00>d
d |j<05><00>d g<07>t<06>d <0A>dStd|j<03>d<0F><03>dS)z%Ensure PulseAudio virtual sink existszChecking virtual sink...)<04>pactl<74>listZsinks<6B>shortT)<02>capture_output<75>textzCreating virtual sink: rVz load-modulezmodule-null-sinkz
sink_name=z@sink_properties=device.description='Soprano_to_RVC_Virtual_Sink'zrate=z
channels=2g<00>?u✓ Virtual sink 'z' already existsN)<08>print<6E>
subprocess<EFBFBD>runrO<00>stdoutrT<00>time<6D>sleep)r@<00>resultr4r4r;<00>ensure_virtual_sinkds"<06> 

<06>z#UnifiedPipeline.ensure_virtual_sinkc
Cstd<01>td<02>td<03>ttjd<04><02>6}t|<01><01>"t|<01><01>tdd<06>|_Wd<00>n1s-wYWd<00>n1s<wYWd<00>n1sKwYz&tj |j
|j dd d
d <0B>|_ |j <0C> <0A>td <0C>td |j
<EFBFBD>d|j <0B>d<0F><05>WdSty<>}ztd|<02><00><02><00>d}~ww)zInitialize Soprano TTS<54>G
======================================================================zInitializing Soprano TTS...<2E>F======================================================================r=Zcuda)<01>deviceNr%<00>float32i)rer$r&<00>dtype<70> blocksizeu(✓ Soprano TTS initialized successfullyz
Output: z (z Hz, stereo)u!✗ Failed to open audio stream: )r[r5<00>os<6F>devnullrrrr <00>sdZ OutputStreamrOrTrQ<00>start<72> Exception)r@rj<00>er4r4r;<00>initialize_soprano|s6<1C><02><02><1C><08>
 <08><02>z"UnifiedPipeline.initialize_sopranocsZtd<01>td<02>td<03><00>fdd<05>}tj|dd<07><02>_d<06>_<04>j<03><05>t<06>d<08>td <09>d
S) z'Start headless RVC in a separate threadrcz Starting RVC Voice Conversion...rdc
sVddl}|<00>d<02><01>|j<03>|<00>d<03><01>|j<03>ddlm}m}ttj d<05><02><>}t
|<03><01><>t |<03><01>|id<06>j j <0A>d<07>j j<0E>d<08>j j<0F>d <09>j j<10>d
<EFBFBD>j j<11>d <0B>j j<12>d <0C>j j<13>d <0A>j j<14>d<0E>j j<15>d<0F>j j<16>d<10>j j<17>d<11>j j<18>d<12>j j<19>d<13>j j<1A>d<14>j j<1B>d<15>j j<1C>d<16>j j<1D><01>j j<1E>j j<1F>j j <20>j j!d<17><04>}||<04>}||<05><01>_"<22>j"<22>#<23>Wd<00>n1s<>wYWd<00>n1s<>wYWd<00>n1s<>wY<00>j$r<>t%<25>&d<18><00>j$s<>ttj d<05><02>?}t
|<03><01>!t |<03><01> <00>j"<22>'<27>Wd<00>n1s<>wYWd<00>n1<00>s wYWd<00>dSWd<00>dS1<00>s$wYdS)NrZfaissZfairseq)<02> HeadlessRVC<56>HeadlessRVCConfigr=<00>pth_path<74>
index_pathrrrrrrrr!r"r$r&r'r(r)r+)r,r-r.r0<><E79A99><EFBFBD><EFBFBD><EFBFBD>?)(<28>logging<6E> getLogger<65>setLevel<65>ERRORZ headless_rvcrprqr5rirjrrrNrrrrrrrrrr!r"r$r&r'r(r)r+r,r-r.r0ZrvcrlrRr_r`<00>stop)rurprqrj<00> config_dictZ
gui_config<EFBFBD>r@r4r;<00>run_rvc<76>s<><02><02><02><02><02><02><02><02> <02>
<02> <02> <02> <02><02><02><02><02><08>
 <1C><02><02><1C>
<06> <1C><02> <0E>$<24>z*UnifiedPipeline.start_rvc.<locals>.run_rvcT)<02>target<65>daemonru ✓ RVC initialized successfullyN)r[<00> threading<6E>ThreadrPrRrlr_r`)r@r|r4r{r;<00> start_rvc<76>s 2

 zUnifiedPipeline.start_rvcc
Cs<>|durdSt<00>|<01>r|<01><02><00><03>}t|<01>dkrdS|<01>tj<07>}|j|j kr7t
t|<01>|j |j<00>}t <0B> ||<02>}tj |dddd<04>}t<06>|dd<06>}|jdkrSt<06>||f<02>}z |j<11>|<01>WdStyv}ztd|<03><00><02>WYd}~dSd}~ww) z)Stream an audio chunk to the virtual sinkNrr)<03>nan<61>posinf<6E>neginfg<00><>g<00>?<3F>z&Warning: Failed to write audio chunk: )<15>torchZ is_tensor<6F>cpu<70>numpy<70>len<65>astype<70>nprfrSrTrH<00> scipy_signal<61>resample<6C>
nan_to_num<EFBFBD>clip<69>ndim<69> column_stackrQ<00>writermr[)r@<00> audio_chunkZnum_samples_outputrnr4r4r;<00>stream_audio_chunk<6E>s(
     
<08><02>z"UnifiedPipeline.stream_audio_chunkrZc
Cs<>|<01><00>sdStd|<01><00>dd<04>ttjd<05><02>B}t|<02><01>.t|<02><01>|j<07>|<01>D] }|dur1|<00> |<03>q&Wd<00>n1s<wYWd<00>n1sKwYWd<00>n1sZwYt
j t d|j <00>t
jd<07>}|<00> |<04>tddd<04>dS) z3Process text through TTS and stream to virtual sinkNu
🎤 Processing: T)<01>flushr=rt)rgu ✓ Done
)<0F>stripr[r5rirjrrr <00> infer_streamr<6D>r<><00>zerosrHrTrf)r@rZrjr<>Zsilencer4r4r;<00> process_text<78>s$
<02><02><1C><02><02><1C>
zUnifiedPipeline.process_textcCsz<>|<00><00>|<00><01>|<00><02>td<01>td<02>td<03>td|jjd<05>d<06><03>td<07>td<08>td <09>td
<EFBFBD>td <0B>|jrnztd <0C><01><08>}|<01> <09>d vrJWn+|rQ|<00>
|<01>Wnt y[Yn!t ycYn w|js;W|<00> <0A>dSW|<00> <0A>dSW|<00> <0A>dSW|<00> <0A>dSW|<00> <0A>dS|<00> <0A>w)zRun the unified pipelinercz"UNIFIED SOPRANO TTS + RVC PIPELINErdu,
✓ Ready! Voice conversion active (pitch: z+dz semitones)z
Commands:z0 - Type text and press Enter to generate speechz! - Type 'quit' or 'exit' to stopz - Press Ctrl+C to stopzG======================================================================
u💬 > )<03>quit<69>exit<69>qN)rbror<>r[rNrrR<00>inputr<74><00>lowerr<72><00>EOFError<6F>KeyboardInterrupt<70>cleanup)r@rZr4r4r;r] sH  
<04>  <02><08> <02> <02> <02> <02>zUnifiedPipeline.runcCsZtd<01>d|_|jr|j<02><03>|j<02><04>|jr#|j<05><06>r#|jjdd<04>td<05>td<06>dS)zClean up resourcesu
⏹️ Stopping...Fr%)<01>timeoutu ✓ Stoppedu👋 Goodbye!
N)r[rRrQry<00>closerP<00>is_alive<76>joinr{r4r4r;r<>1s

 zUnifiedPipeline.cleanupN)rM)rBrCrDrErrFrUrbror<>r<>r<>r]r<>r4r4r4r;rLTs @" %rLcCs<>tjdtjdd<03>}|jdtdd<06>|jdtdd<06>|jd td
d<06>|jd td d<06>|jd tddd<10>|jdtddd<10>|jdtddd<10>|jdtddd<10>|jdtddd<10>|jdtddd<10>|jd td!gd"<22>d#d$<24>|jd%td&d'd<10>|jd(td)d<06>|jd*td+d,d<10>|jd-td.d/d<10>|jd0td1d2d<10>|jd3d4d5d6<64>|jd7d4d8d6<64>|jd9d4d:d6<64>|jd;td<d=d<10>|<00><07>}|jr<>t d>|j<08><00><02>t
<EFBFBD> |j<08>}nU|j r<>|j s<>|<00>d?<3F>t
dSid@|j <0C>dA|j <0A>dB|j<0F>dC|j<10>dD|j<11>dE|j<12>dF|j<13>dG|j<14>dH|j<15>dI|j<16>dJ|j<17>dK|j<18>dL|j<19>dM|j<1A>dN|j<1B>dO|j <00>dP|j<1D><01>}|j<1E>r7|<02>|j<1E>t dQ|j<1E><00><02>dSt ||j!dR<64>}|<03>"<22>dS)TNz"Unified Soprano TTS + RVC PipelineaW
Examples:
# Run with command-line arguments
python unified_soprano_rvc.py --pth model.pth --index model.index --pitch 0
# Load from config file
python unified_soprano_rvc.py --config rvc_config.json
# Save current config
python unified_soprano_rvc.py --pth model.pth --index model.index --save-config my_config.json
)<03> description<6F>formatter_class<73>epilogz--configz%Load RVC configuration from JSON file)<02>type<70>helpz --save-configz(Save configuration to JSON file and exitz--pthzPath to RVC model (.pth file)z--indexzPath to index filez--pitchrz%Pitch shift in semitones (default: 0))r<><00>defaultr<74>z --formantrzFormant shift (default: 0.0)z --index-raterzIndex rate (default: 0.75)z--filter-radiusrzFilter radius (default: 3)z--rms-mix-raterzRMS mix rate (default: 0.25)z --protectrz,Protect voiceless consonants (default: 0.33)z
--f0methodr)rZharvestZcrepeZfcpez%F0 extraction method (default: rmvpe))r<>r<><00>choicesr<73>z--input-devicer z1Input audio device for RVC (default: soprano_rvc)z--output-devicez-Output audio device (default: system default)z --samplerater#zSample rate (default: 48000)z--n-cpur*z2Number of CPU cores for F0 extraction (default: 4)z --thresholdr/z&Silence threshold in dB (default: -60)z--I-noise-reduce<63>
store_truezEnable input noise reduction)<02>actionr<6E>z--O-noise-reducezEnable output noise reductionz --no-use-pvzDisable phase vocoderz--virtual-sinkrMz.Name of virtual sink (default: soprano_to_rvc)zLoading configuration from: z0--pth and --index are required (or use --config)rrrrrrrrrr!r"r$r+r,r-r.r0u✓ Configuration saved to: )rOr4)#<23>argparse<73>ArgumentParserZRawDescriptionHelpFormatter<65> add_argumentrFrHrI<00>
parse_args<EFBFBD>configr[rr<rr<00>errorrrrrrrrr!r"r$r+r,r-Z no_use_pvr0Z save_configrArLZ virtual_sinkr])<04>parser<65>argsrN<00>pipeliner4r4r;<00>mainAs<><06>
<06>
<06>
<06> 
<02><02><02><02><02><02><02><02> <02>
<02> <02> <02> <02><02><02><02><04>  r<><00>__main__)-rE<00>sysrir6r<>rr_r\<00>warningsru<00>pathlibr<00> dataclassesrr<00>typingr<00>
contextlibrr<00> basicConfig<69>INFOrvrw<00>filterwarnings<67>environ<6F>path<74>insertrF<00>__file__<5F>parentr<74>r<>Z sounddevicerk<00>scipyrr<>r<>r rrrLr<>rBr4r4r4r;<00><module>sH  <06>


  %n]
<04>