The error signals that your RVC session lacks a target sample rate; update the WebUI and extract a proper checkpoint with tgt_sr to restore conversion.
Seeing AttributeError: 'RVC' object has no attribute 'tgt_sr' during conversion or real-time voice work means the running RVC instance never received a valid target sample rate for the model. In most cases it traces back to an outdated WebUI build, a model copied the wrong way, or a checkpoint extracted without the target rate metadata. The RVC WebUI issue tracker shows this exact crash in multiple reports where GUI code tries to read self.rvc.tgt_sr and fails.
What The Error Really Means
Quick scan: the GUI expects a target sample rate stored on the RVC object, often as tgt_sr. When the loaded model or config lacks that field, any step that sets the GUI samplerate from rvc.tgt_sr raises the attribute error. The project’s issue pages include stack lines such as self.gui_config.samplerate = self.rvc.tgt_sr just before the crash, which confirms the missing attribute path.
Another common trigger is moving raw training .pth files straight into weights without using the built-in extraction flow. The project wiki warns that copying big .pth files can yield missing keys such as tgt_sr and pitch flags, and it tells you to extract the compact model with the ckpt tab so the target sample rate is recorded.
AttributeError: ‘RVC’ Object Has No Attribute ‘Tgt_Sr’ — Causes And Fixes
Core idea: make sure the running WebUI is current, the model was extracted through the tool that writes the metadata, and the session reads the same target rate that the model expects. Start with the fastest checks, then move to rebuild steps if needed. The general RVC library and the WebUI evolve quickly, so matching versions and proper model packaging matter.
Fast Checks You Can Do Now
- Confirm The Build — Launch a recent Retrieval-based-Voice-Conversion-WebUI build. Older GUI snapshots reference
rvc.tgt_srand crash when the attribute never populates. Fresh builds include fixes and clearer extraction paths. - Use The Ckpt Tab — Re-extract your model from the training
.pthwith the ckpt tab, selecting the correct pitch option and target sample rate. This writes the smaller, inference-ready files and thetgt_srvalue the UI expects. - Avoid Raw File Copy — Don’t drag the several-hundred-MB training checkpoints into weights. The wiki notes that direct copies often miss keys like
tgt_sr. - Match Model And GUI Settings — Open the model card/metadata after extraction and verify the target rate (often 40k or 48k). Set the same output samplerate in the GUI; mismatches cause read/write issues seen around
tgt_srin issue threads.
Short Table Of Symptoms
| Symptom | Likely Cause | Fix |
|---|---|---|
Crash at convert start with missing tgt_sr |
Outdated GUI reads rvc.tgt_sr that was never set |
Update WebUI to a recent build; reload model |
| Model loads, then error on samplerate line | Model was copied directly; no metadata key | Re-extract via ckpt tab with target rate selected |
| No audio file saved after conversion | Output step lacks correct sample rate | Set a valid rate (e.g., 40k/48k) that matches the model |
Natural Keyword Variant For Clarity: Fixing Tgt_Sr Attribute In RVC Webui Now
Why this helps: a clean extraction path writes the target sample rate into the small checkpoint, and a current GUI reads it without extra flags. A handful of GitHub threads point at tgt_sr assignments inside GUI code; the crash appears when the field is missing. Keeping the WebUI current and using the official extraction step removes that gap.
Step-By-Step Fix That Works
Start fresh: close the running session. If you use a portable folder build, keep a backup of your logs and weights directories first.
- Update The Webui — Pull or download the latest Retrieval-based-Voice-Conversion-WebUI release to pick up GUI and backend fixes tied to conversion and metadata handling.
- Re-Extract The Checkpoint — Open the ckpt tab, point to your training
.pth, choose whether you trained with pitch, and set the target samplerate. Run extraction to produce the smaller inference files that includetgt_sr. - Load The Extracted Model — Select the new model in weights. In the GUI, confirm the output samplerate matches what you set during extraction (e.g., 48k). A mismatch can also break saving.
- Test A Known-Good Clip — Use a short WAV at the same or higher rate than the target. A known-good sample keeps troubleshooting focused on the model rather than a bad input file. Community threads show varied inputs; control the variable first.
- Restart Real-Time Mode — If you use the real-time GUI, relaunch it after loading the corrected model so the samplerate propagates to the live path. In old threads the crash occurs right as the live path reads
rvc.tgt_sr.
When You Still See The Crash
Check the path: make sure you are running the official WebUI, not a separate launcher that bypasses parts of the interface. One report referenced a real-time program that uses a different UI toolkit; in that setup, fields and attributes may diverge from WebUI expectations. If your launcher wires the session differently, the GUI line that assumes tgt_sr on the RVC object will fail.
- Open The Log — Scroll to the first line where samplerate is read; confirm the code path says
self.rvc.tgt_sror similar. If so, your model extraction likely missed the key. - Rebuild The Model — Run extraction again and select the same target rate you intend to output. The project wiki singles out
tgt_sras a missing key when users copy raw checkpoints. - Pick A Stable Rate — Many community snippets reference rates like 40k or 48k. Match this across extraction, conversion, and saving. One issue shows the write call using
tgt_srduring file save.
Clean Setup Tips That Prevent Recurrence
Fresh install path: if you frequently train and convert, keep a clean WebUI folder for inference only. Place extracted models in weights, keep training .pth files elsewhere, and document which rate you used per model.
- One Model, One Rate — Stick to a single target rate per model build; label folders with the rate. This avoids silent mismatches during batch runs.
- Use The Webui’s Tools — Prefer the built-in extraction and conversion pages over hand-moved scripts. The GUI writes the format and metadata that the rest of the pipeline reads.
- Track Versions — When you update WebUI, also record the model’s extraction date. Issue threads show code moving fast; small GUI changes shift how fields are read.
Why Extraction Matters For Tgt_Sr
One note: the RVC project ships a reusable library and a WebUI. Even when the core library supports a sample rate, the WebUI needs the value in the light model files it loads at inference time. That’s what the ckpt tab writes. Skipping that step leaves the running object without tgt_sr, and the next read in the GUI crashes.
Exact Keyword Usage For Traceability
Here is the original string you may find in logs: AttributeError: ‘RVC’ object has no attribute ‘tgt_sr’. Keep this exact case when searching the project issues; the reports that match your stack tend to include the GUI line that reads from self.rvc.tgt_sr.
If your console shows AttributeError: ‘RVC’ Object Has No Attribute ‘Tgt_Sr’ with the uppercase style, it describes the same problem. The fix set above still applies: update the WebUI, extract the model with the target sample rate, and reload the session.
Model Handling Checklist
- Verify The Build — Launch a recent WebUI build before loading models.
- Extract With Ckpt — Use the ckpt tab; don’t drop raw training checkpoints into weights.
- Set Target Rate — Pick a rate (e.g., 48k) during extraction and match it in output.
- Retest Real-Time Mode — Restart the live UI after loading the corrected model.
Troubleshooting Edge Cases
Different launcher: if you are running a separate “realtime” program that isn’t the standard WebUI, attribute names or wiring may differ. One reporter mentioned a toolkit swap, which means your UI code might never set the field that the WebUI expects. In that case, move back to the official WebUI or adapt your script to pass a sample rate into the RVC object before conversion.
Broken save path: if conversion runs but no file writes, check the write call’s samplerate parameter. Community notes show save lines that use tgt_sr; if that’s missing or mismatched, the file step fails.
Wrap-Up Actions
- Update The Webui Build — Replace old snapshots that reference missing fields.
- Re-Extract Every Model — Use the ckpt tab so the small files include
tgt_srand pitch info. - Match Rates End-To-End — Keep the target rate consistent across extraction, conversion, and saving.
