inference-cli.py is not compatible with app.py
Can you update inference-cli.py file?
Imports are wrong and it doesn't work like it should in terminal.
from infer.utils_infer import (
load_checkpoint,
save_spectrogram,
)
from model.utils import (
convert_char_to_pinyin,
get_tokenizer,
)
those files are from original repo and not needed to run app.py
For me it would be better to use inference_cli.py because then we can run it in terminal and in external applications.
Other solution would be to create fork from your repository and updating that file every time you change something.
It would be much easier to maintain 2 files in one repository by owner instead updating it every change in fork.
can you see if this will work ?
Key Arguments to Remember:
-c, --config: Path to the .toml configuration file.
--ckpt_path: Required (unless in config). Path or Hub ID of the TTS model checkpoint.
--ref_audio: Required (unless in config). Path to the reference audio file.
--ref_text: Transcription of reference audio. If omitted or "", script tries to use Whisper.
--gen_text: Text to synthesize.
--gen_file: Path to a file containing text to synthesize (overrides --gen_text). One of these text sources is required.
--tokenizer_path: Required (unless in config). Path to the tokenizer.json.
--output_dir: Directory to save results. Defaults to . (current directory) if not set.
--output_name: Base name for output files (defaults to out).
--ref_language, --language: Language codes for phonemization (defaults usually en-us).
--remove_silence: Use this flag without a value to enable silence removal (e.g., --remove_silence). To explicitly disable it if it's enabled in the config, use --no-remove_silence.
--speed, --nfe, --cfg, --sway, --cross_fade: Control inference parameters.
--device, --dtype: Manually set hardware device and data type.
--hf_token: Provide Hugging Face token if needed for private models.
python inference-cli.py
--ckpt_path "hf://Gregniuki/F5-tts_English_German_Polish/multi3/model_900000.pt"
--ref_audio "path/to/your/reference.wav"
--gen_text "Synthesize this sentence from the command line without a config file."
--tokenizer_path "data/Emilia_ZH_EN_pinyin/tokenizer.json"
--output_dir "./generated_audio"
--output_name "no_config_test"
--ref_language "en-us"
--language "en-us"
# Add any other parameters you want to set, like --speed, --nfe, etc.
Example overriding specific settings: Let's say you use inference-cli.toml but want to generate different text and save it with a different name:
python inference-cli.py
--gen_text "This is a test using command line arguments."
--output_name "cli_override_test"
--remove_silence # Add this flag to enable silence removal
Run the Script:
If your config file is named inference-cli.toml and is in the same directory as the script, you can just run:
python inference-cli.py
No. It not working.
I'm trying to generate polish audio so I set :
inference-cli.toml file:
model = "F5-TTS"
ref_audio = "/media/username/disk/sample.wav"
ref_text = ""
gen_text = "Kiedy nieprzenikniony, zimny powiew północnych wiatrów sprawił, że nawet najbardziej uparta zieleń zaczęła marznąć, stary pszczelarz, który przez dziesięciolecia z pasją opiekował się setkami uli, usiadł na starannie wykonanym, choć niegdyś niezwykle eleganckim krześle, zastanawiając się, czy nadchodzące zmiany klimatyczne nie zagrożą nie tylko jego tradycyjnemu rzemiosłu, ale także całej wiejskiej społeczności, której codzienne życie od wieków opierało się na harmonii z naturą."
gen_file = ""
remove_silence = false
output_dir = "/media/username/disk/"
ref_language = "pl-pl"
language = "pl-pl"
command:
python inference-cli.py
Output:
Donwload Vocos from huggingface charactr/vocos-mel-24khz
Using cuda device
Kiedy nieprzenikniony, zimny powiew północnych wiatrów sprawił, że nawet najbardziej uparta zieleń zaczęła marznąć, stary pszczelarz, który przez dziesięciolecia z pasją opiekował się setkami uli, usiadł na starannie wykonanym, choć niegdyś niezwykle eleganckim krześle, zastanawiając się, czy nadchodzące zmiany klimatyczne nie zagrożą nie tylko jego tradycyjnemu rzemiosłu, ale także całej wiejskiej społeczności, której codzienne życie od wieków opierało się na harmonii z naturą.
Converting audio...
Audio is over 15s, clipping to only first 15s.
No reference text provided, transcribing reference audio...
Device set to use cuda
/media/username/disk/f5-tts_Polish_English_German/.venv/lib/python3.10/site-packages/transformers/models/whisper/generation_whisper.py:573: FutureWarning: The input name `inputs` is deprecated. Please make sure to use `input_features` instead.
warnings.warn(
You have passed task=transcribe, but also have set `forced_decoder_ids` to [[1, None], [2, 50360]] which creates a conflict. `forced_decoder_ids` will be ignored in favor of task=transcribe.
The attention mask is not set and cannot be inferred from input because pad token is same as eos token. As a consequence, you may observe unexpected behavior. Please pass your input's `attention_mask` to obtain reliable results.
Finished transcription
ref_text W głowie Harrego działo się coś dziwnego i bardzo nieprzyjemnego. Kiedy opowieść Hagrida dobiegła końca, znowu ujrzał oślepiający błysk zielonego światła, ale tym razem o wiele wyraźniej niż mu się to zdarzało wcześniej i powiem, że to nie jest.
gen_text 0 Kiedy nieprzenikniony, zimny powiew północnych wiatrów sprawił, że nawet najbardziej uparta zieleń zaczęła marznąć, stary pszczelarz,
gen_text 1 który przez dziesięciolecia z pasją opiekował się setkami uli, usiadł na starannie wykonanym, choć niegdyś niezwykle eleganckim krześle, zastanawiając się,
gen_text 2 czy nadchodzące zmiany klimatyczne nie zagrożą nie tylko jego tradycyjnemu rzemiosłu, ale także całej wiejskiej społeczności,
gen_text 3 której codzienne życie od wieków opierało się na harmonii z naturą.
Generating audio using F5-TTS in 4 batches, loading models...
0%| | 0/4 [00:00<?, ?it/s]Building prefix dict from the default dictionary ...
Loading model from cache /tmp/jieba.cache
Loading model cost 0.339 seconds.
Prefix dict has been built successfully.
100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:08<00:00, 2.12s/it]
/media/username/disk/out.wav
/media/username/disk/out.png
But output is nothing I would expect:
My changes in inference-cli.py:
diff --git a/inference-cli.py b/inference-cli.py
index 3d6e3d2..1600dbb 100644
--- a/inference-cli.py
+++ b/inference-cli.py
@@ -17,8 +17,17 @@ from transformers import pipeline
from vocos import Vocos
from model import CFM, DiT, MMDiT, UNetT
-from model.utils import (convert_char_to_pinyin, get_tokenizer,
- load_checkpoint, save_spectrogram)
+
+from infer.utils_infer import (
+ load_checkpoint,
+ save_spectrogram,
+)
+
+from model.utils import (
+ convert_char_to_pinyin,
+ get_tokenizer,
+)
+
parser = argparse.ArgumentParser(
prog="python3 inference-cli.py",
@@ -232,8 +241,10 @@ def infer_batch(ref_audio, ref_text, gen_text_batches, model, remove_silence, cr
)
generated = generated[:, ref_audio_len:, :]
+
generated_mel_spec = rearrange(generated, "1 n d -> 1 d n")
- generated_wave = vocos.decode(generated_mel_spec.cpu())
+ generated_wave = vocos.decode(generated_mel_spec.to(torch.float32).cpu())
+
if rms < target_rms:
generated_wave = generated_wave * rms / target_rms
I used Gemini 2.5 experimental to update inference-cli.py I don't know if it's working properly but Reference for Polish language should be "pl"
I tested "pl" but it's the same result.
I'll try to change app.py to new version of inference_cli.py just to have working cli tool but after that - can you add it to your repository and update it everytime you will update app.py?
Problem is with somewhere with text_to_ipa or infer_baches function as Gemini modify code and ref_text and gen_text are processed outside infer_batches function.