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

122 lines
13 KiB
Plaintext
Raw Normal View History

o
<00>uei<65>O<00>@s
UdZddlZddlZddlZddlZddlZddlZddlZddlZddl m
Z
ddl m Z m Z ddlZddlZddlmZmZmZddlmZmZddlmZmZddlZejejdd <09>e<04>e <20>Z!dd
l"m#Z#m$Z$dd l%m&Z&m'Z'ed d dd<0F>Z(da)e e#e*d<e<05>+<2B>Z,e<08>-<2D>Z.da/Gdd<13>d<13>Z0Gdd<15>de<1A>Z1Gdd<17>de<1A>Z2e(<28>3d<18>dd<1A><00>Z4e(<28>3d<1B>dd<1D><00>Z5e(<28>6d<1E>dd <20><00>Z7e(<28>6d!<21>d"d#<23><00>Z8e(<28>6d$<24>d%d&<26><00>Z9e(<28>:d'<27>d(e1fd)d*<2A><04>Z;e(<28>:d+<2B>d(e1fd,d-<2D><04>Z<e(<28>:d.<2E>d(e1fd/d0<64><04>Z=d1d2<64>Z>e d3k<02>re><3E>dSdS)4zj
FastAPI Server for Soprano TTS + RVC Pipeline
Provides HTTP API for text-to-speech with voice conversion
<EFBFBD>N)<01>Path)<02>Optional<61>List)<03>FastAPI<50> HTTPException<6F>BackgroundTasks)<02>StreamingResponse<73> JSONResponse)<02> BaseModel<65>Fieldz4%(asctime)s - %(name)s - %(levelname)s - %(message)s)<02>level<65>format)<02>UnifiedPipeline<6E> RVCConfig)<02> HeadlessRVC<56>HeadlessRVCConfig<69>Soprano TTS + RVC APIz.Text-to-speech with real-time voice conversion<6F>1.0.0)<03>title<6C> description<6F>version<6F>pipelineFc@sHeZdZdZdejfdd<04>Zdd<06>Zdd<08>Zd d
<EFBFBD>Z d d <0C>Z
d d<0E>Z dS)<10>AudioCaptureStreamzAStream that captures audio data to a buffer instead of playing it<69>buffercCs||_d|_d|_dS)N逻<00>)r<00>
samplerate<EFBFBD>channels)<02>selfr<00>r<00>'/data/NVMe/AI/soprano2RVC/api_server.py<70>__init__4s
zAudioCaptureStream.__init__cCs|j<00>|<01><02><00>dS)zCapture audio data to bufferN)r<00>put<75>copy)r<00>datarrr <00>write9szAudioCaptureStream.writecC<00>dS<00>zNo-op for compatibilityNr<00>rrrr <00>start=<00>zAudioCaptureStream.startcCr&r'rr(rrr <00>stopAr*zAudioCaptureStream.stopcCr&r'rr(rrr <00>abortEr*zAudioCaptureStream.abortcCr&r'rr(rrr <00>closeIr*zAudioCaptureStream.closeN) <0C>__name__<5F>
__module__<EFBFBD> __qualname__<5F>__doc__<5F>queue<75>Queuer!r%r)r+r,r-rrrr r2s rc@sNeZdZUeddddd<05>Zeed<eddd <09>Zeed
<ed d d <09>Ze ed <dS)<0F>
TTSRequest.zText to synthesize<7A>i<>)r<00>
min_length<EFBFBD>
max_length<EFBFBD>text<78>wavzAudio format (wav, mp3, flac))<02>defaultrr rzOutput sample rate in Hz<48> sample_rateN)
r.r/r0r r8<00>str<74>__annotations__r r;<00>intrrrr r4Ns
r4c@s>eZdZUeed<eed<dZeeed<dZ ee
ed<dS)<06> TTSResponse<73>success<73>messageN<65> audio_lengthr;) r.r/r0<00>boolr=r<rBr<00>floatr;r>rrrr r?Ts
r?<00>startupc<00>s<><00>t<00>d<01>tt<03>jd}|<00><05>s t<00>d|<00><00><02>td|<00><00><02><01>t<00>d|<00><00><02>t<08> t
|<00><01>}t<00>d<05>t |<01>a t <0C> <0A>t<00>d<06>t <0C><0E>t<00>d<07>t <0C><0F>t<00>d<08>d S)
z"Initialize the pipeline on startupzStarting API server...zrvc_config.jsonzConfiguration file not found: zLoading configuration from: z*Initializing Soprano TTS + RVC pipeline...zLoading Soprano TTS model...z Starting RVC voice conversion...u✓ API server ready!N)<10>logger<65>infor<00>__file__<5F>parent<6E>exists<74>error<6F> RuntimeErrorr<00> from_filer<rr<00>ensure_virtual_sink<6E>initialize_soprano<6E> start_rvc)<02> config_path<74>
rvc_configrrr <00> startup_event[s <02>



rS<00>shutdownc<00>s&<00>t<00>d<01>tr t<02><03>t<00>d<02>dS)zCleanup on shutdownzShutting down API server...u✓ Shutdown completeN)rFrGr<00>cleanuprrrr <00>shutdown_event}s
<02>
rV<00>/c <00>s&<00>ddtrdndddddd d
<EFBFBD>d d <0C>S) zRoot endpoint - API inforr<00>running<6E> initializingu1/api/v1/synthesize (FULL PIPELINE: Soprano→RVC)z2/api/v1/synthesize/soprano-only (TTS only, no RVC)z./api/v1/synthesize/stream (Streaming with RVC)<29>/health<74>/config)<05>
synthesize<EFBFBD>synthesize_soprano_only<6C>synthesize_stream<61>health<74>configzMDefault /synthesize endpoint now uses FULL pipeline with RVC voice conversion)<05>servicer<00>status<75> endpoints<74>note)rrrrr <00>root<6F>s<02>
<04><06>rerZc<00>s8<00>tdur tddd<04><02>dtjdutjduotj<03><04>d<06>S)zHealth check endpointN<74><4E><00>Pipeline not initialized<65><02> status_code<64>detail<69>healthy)rb<00>soprano_loaded<65> rvc_running)rr<00>soprano<6E>
rvc_thread<EFBFBD>is_aliverrrr <00> health_check<63>s<02> <06>rqr[c
<00>sR<00>tdur tddd<04><02>tjjtjjtjjtjjtjjtjjtjj tjj
tjj d<05> S)zGet current RVC configurationNrfrgrh) <09>pth_path<74>
index_path<EFBFBD>pitch<63>
index_rate<EFBFBD>f0method<6F> input_device<63> output_device<63>formant<6E>use_pv) rrrR<00>pth<74>indexrtrurvrwrxryrzrrrr <00>
get_config<EFBFBD>s<02> <06>r}z/api/v1/synthesize<7A>requestc <00>s\<00>tdur tddd<04><02>t4IdH<00><02><00>z<>t<03>d|jdd<06><00>d<07><03>t<06><07>s<zt<06><08>Wn
t j
y7Ynwt<06><07>r'da t<03>d <09>id
tj j <0A>d tj j<0E>d tj j<0F>d tj j<10>dtj j<11>dtj j<12>dd<01>dd<12>dd<14>dd<16>dd<18>dd<1A>dd<1C>dtj j<13>dtj j<14>dtj j<15>d tj j<16>tj jtj jtj jd!d"<22><04>}t|<01>}t|<02>}|<03><1C>g}t<03>d#<23>tj<1D>|j<05>D]<5D>}t|d$<24>r<>|<05> <20><00>!<21>}|j"d%kr<>|<05>#<23>}d&d'l$m%}t&t'|<05>dd(<00>}|<06>(||<07>}t)j*|d)d*d+d,<2C>}t)<29>+|d+d*<2A>}t)<29>,||f<02><01>-t)j.<2E>} t)<29>/| <09>}
z|<03>0| |
t'| <09>dd<01>|<04>1|
dd<01>d&f<00>Wq<>t2<74>y7} zt<03>3d-| <0B><00><02>|<04>1|<08>WYd} ~ q<>d} ~ ww|<04>sAtd.d/d<04><02>t)<29>4|<04>} t<03>d0t'| <0C>dd1<64>d2<64><03>|j5dk<03>rkt&t'| <0C>|j5d<00>}|<06>(| |<07>} t)j*| d)d*d+d,<2C>} t)<29>+| d+d*<2A>} t6<74>7<EFBFBD>} |j8d3k<02>r<>t9j:| | |j5d4d5<64>d6}n0|j8d7k<02>r<>t9j:| | |j5d8d5<64>d9}n|j8d:k<02>r<>t9j:| | |j5d;d5<64>d<}n
td.d=|j8<6A><00>d<04><02>| <0A>;d&<26>t'| <0C>|j5}t<03>d>|d1<64>d?<3F><03>d@a t<| |dA|j8<6A><00>t=|<0F>t=|j5<6A>dBdC<64>dD<64>WWd<00>IdHSt2<74>y} zd@a tj>dEt=| <0B><01><00>ddF<64>tdGdHt=| <0B><01><00>d<04><02>d} ~ ww1IdH<00>s'wYdS)Iuz
Synthesize speech from text through the FULL pipeline (Soprano TTS → RVC)
Returns RVC-processed audio file
NrfrgrhzProcessing synthesis request: '<27>2u*...' through FULL pipeline (Soprano→RVC)Tz$Setting up RVC with audio capture...rrrsrtrurvrwrxrr<00>
block_time<EFBFBD><00>?<3F>crossfade_time<6D>{<14>G<EFBFBD>z<EFBFBD>?<3F>
extra_time<EFBFBD>@<40>n_cpu<70><00> threshold<6C>N<>ry<00> filter_radius<75> rms_mix_rate<74>protectr<00><04>I_noise_reduce<63>O_noise_reducerzrz%Generating speech with Soprano TTS...<2E>cpur5r<00><01>signal<61>}<00><00><00>?<3F><00><><EFBFBD><03>nan<61>posinf<6E>neginfzRVC processing error: <20><><00>No audio generatedz'RVC processing complete. Audio length: <20>.2f<EFBFBD>sr9<00>WAV<41>r <00> audio/wav<61>mp3<70>MP3<50>
audio/mpeg<65>flac<61>FLAC<41>
audio/flac<61>Unsupported format: <20>
Generated zs of RVC-processed audioFz#attachment; filename=synthesis_rvc.zSoprano-TTS-RVC<56><04>Content-DispositionzX-Audio-Duration<6F> X-Sample-Rate<74>X-Processed-By<42><02>
media_type<EFBFBD>headers<72>Synthesis error: <20><01>exc_info<66><6F><00>Synthesis failed: )?rr<00> pipeline_lockrFrGr8<00>audio_capture_buffer<65>empty<74>
get_nowaitr2<00>Empty<74>capture_enabledrRr{r|rtrurvrwryr<>r<>r<>r<>r<>rzrr<00>initialize_rvcrn<00> infer_stream<61>hasattrr<72><00>numpy<70>ndim<69>squeeze<7A>scipyr<79>r><00>len<65>resample<6C>np<6E>
nan_to_num<EFBFBD>clip<69> column_stack<63>astype<70>float32<33>
zeros_like<EFBFBD>audio_callback<63>append<6E> Exception<6F>warning<6E> concatenater;<00>io<69>BytesIOr <00>sfr%<00>seekrr<rK)r~<00> config_dictrR<00> headless_rvc<76>collected_audio<69>chunk<6E> scipy_signal<61> num_samples<65> chunk_48k<38> chunk_stereo<65> output_chunk<6E>e<>
audio_data<EFBFBD> audio_bufferr<72><00>durationrrr r\<00>s<><02>  <02><08>
<02><02><02><02><02><02><02><02> <02>
<02> <02> <02> <02><02><02><02><02><08>

 
  
<08><02> 
     

<04><06><16><08><02><00><1C>r\z/api/v1/synthesize/soprano-onlyc
<00>sX<00>tdur tddd<04><02>t4IdH<00><01> z<>t<03>d|jdd<06><00>d<07><03>g}tj<06>|j<05>D]7}t|d<08>r8|<02> <09><00>
<EFBFBD>}|j d krA|<02> <0C>}|j d
kr]d d lm}tt|<02>|j d
<00>}|<03>||<04>}|<01>|<02>q+|sktd dd<04><02>t<14>|<01>}tj|dddd<12>}t<14>|dd<10>}t<18><19>}|jdkr<>tj|||j dd<15>d}n.|jdkr<>tj|||j dd<15>d}n|jdkr<>tj|||j dd<15>d}n
td d|j<1A><00>d<04><02>|<06>d <0B>t|<05>|j }t<03>d|d<1F>d <20><03>t||d!|j<1A><00>t|<08>t|j <0A>d"d#<23>d$<24>WWd<00>IdHSt <20>y} ztj!d%t| <09><01><00>d&d'<27>td(d)t| <09><01><00>d<04><02>d} ~ ww1IdH<00>s%wYdS)*z<>
Synthesize speech using ONLY Soprano TTS (no RVC voice conversion)
Use this for comparison or if you want raw TTS output
Nrfrgrhz$Processing Soprano-only synthesis: 'r<00>...'r<>r5r<>rr<>r<>r<>r<>r<>r<>r<>r9r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>zs of Soprano-only audioz'attachment; filename=synthesis_soprano.zSoprano-TTS-Onlyr<79>r<>r<>Tr<54>r<>r<>)"rrr<>rFrGr8rnr<>r<>r<>r<>r<>r<>r;r<>r<>r>r<>r<>r<>r<>r<>r<>r<>r<>r<>r r<>r%r<>rr<r<>rK)
r~<00> audio_chunksr<73>r<>r<>r<>r<>r<>r<>r<>rrr r]Rsh<02> 
 

    





<04><06><16>B<08><02><1C>r]z/api/v1/synthesize/streamc<00>s@<00>tdur tddd<04><02><01>fdd<06>}t|<01>ddt<03>j<04>d d
<EFBFBD>d <0B>S) u<>
Stream audio chunks through FULL pipeline (Soprano TTS → RVC) as they're generated
Note: Streaming with RVC may have latency due to processing
Nrfrgrhc s~<00><02>z"t<00>d<01>jdd<03><00>d<04><03>idtjj<05>dtjj<06>dtjj<07>dtjj<08>d tjj <09>d
tjj
<EFBFBD>d d<02>d d <0A>dd<0F>dd<11>dd<13>dd<15>dd<17>dtjj <0B>dtjj <0C>dtjj <0A>dtjj<0E>tjjtjjtjjdd<1D><04>}t|<00>}t|<01>}|<02><14>tj<15><16>j<02>D]<5D>}t|d<1E>r<>|<03><18><00><19>}|jdkr<>|<03><1B>}d d!lm}tt|<03>d d"<00>}|<04> ||<05>}t!j"|d#d$d%d&<26>}t!<21>#|d%d$<24>}t!<21>$||f<02><01>%t!j&<26>}t!<21>'|<07>}z|<02>(||t|<07>dd<02>|dd<02>d f} Wnt)y<>}
zt<00>*d'|
<EFBFBD><00><02>|} WYd}
~
nd}
~
ww<00>j+d k<03>rtt| <09><01>j+d <00>}|<04> | |<05>} | d(<00>%t!j,<2C>} | <0B>-<2D>Vqzt<00>d)<29>WdSt)<29>y>}
z tj.d*t/|
<EFBFBD><01><00>d+d,<2C><00>d}
~
ww)-z#Generate RVC-processed audio chunkszStreaming synthesis with RVC: 'Nrr<>rrrsrtrurvrwrxrrr<>r<>r<>r<>r<>r<>r<>r<>r<>r<>ryr<>r<>r<>rr<>r<>r5rr<>r<>r<>r<>r<>r<>zRVC streaming error: i<>zStreaming completezStreaming error: Tr<54>)0rFrGr8rrRr{r|rtrurvrwryr<>r<>r<>r<>r<>rzrrr<>rnr<>r<>r<>r<>r<>r<>r<>r<>r>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r<>r;<00>int16<31>tobytesrKr<) r<>rRr<>r<>r<>r<>r<>r<>r<><00>processed_audior<6F><00> chunk_int16<31>r~rr <00>audio_generator<6F>s<><02><02><02><02><02><02><02><02><02> <02>
<02> <02> <02> <02><02><02><02><02><08>
 
  
<08><02>   <08><02>z*synthesize_stream.<locals>.audio_generatorr<72>z-attachment; filename=synthesis_rvc_stream.wavzSoprano-TTS-RVC-Stream)r<>r<>r<>r<>)rrrr<r;)r~r<>rr<>r r^<00>s<02>  O<04><06>r^cCs<>ddl}|jdd<04>}|jdtddd<08>|jd td
d d<08>|jd d dd<0F>|jdtddd<08>|<01><05>}tjd|j|j |j
|j dd<15>dS)zRun the API serverrNzSoprano TTS + RVC API Server)rz--hostz0.0.0.0zHost to bind to)<03>typer:<00>helpz--porti@zPort to bind toz--reload<61>
store_truezEnable auto-reload)<02>actionr<6E>z --workersr5zNumber of worker processeszapi_server:apprG)<05>host<73>port<72>reload<61>workers<72> log_level) <0C>argparse<73>ArgumentParser<65> add_argumentr<r><00>
parse_args<EFBFBD>uvicorn<72>runr<6E>r<>r<>r<>)r<><00>parser<65>argsrrr <00>mains 
<EFBFBD>r<EFBFBD><00>__main__)?r1<00>osr<73><00>json<6F>logging<6E>asyncio<69> threading<6E>timer2<00>pathlibr<00>typingrrr<>r<><00> soundfiler<65><00>fastapirrr<00>fastapi.responsesrr <00>pydanticr
r r<><00> basicConfig<69>INFO<46> getLoggerr.rF<00>unified_soprano_rvcrrr<>rr<00>apprr=<00>Lockr<6B>r3r<>r<>rr4r?<00>on_eventrSrV<00>getrerqr}<00>postr\r]r^r<>rrrr <00><module>sr <06>
<06>
!



Ob

<04>