Views
No views yet
model_type: "bailingmm" (Ming Omni TTS) in MLX-Audio.1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --text "This is a quick Ming Omni test." \
4 --lang_code en \
5 --output_path "audio_io" \
6 --file_prefix quick_test \
7 --verbose1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --prompt "Please generate speech based on the following description.\n" \
4 --text "Our vision is to build digital infrastructure for future services and bring many small but meaningful improvements to everyday life." \
5 --ref_audio "PATH_TO_AUDIO" \
6 --ref_text "This is a sample reference transcript." \
7 --cfg_scale 2.0 --sigma 0.25 --temperature 0.0 --max_tokens 200 \
8 --lang_code en \
9 --output_path "audio_io" \
10 --file_prefix en_01_tts \
11 --verbose1from pathlib import Path
2import numpy as np
3from mlx_audio.audio_io import write as audio_write
4from mlx_audio.tts.utils import load_model
5
6MODEL = "mlx-community/Ming-omni-tts-16.8B-A3B-bf16"
7OUT = Path("audio_io")
8OUT.mkdir(parents=True, exist_ok=True)
9
10model = load_model(MODEL)
11result = next(
12 model.generate(
13 prompt="Please generate speech based on the following description.\n",
14 text="Our vision is to build digital infrastructure for future services and bring many small but meaningful improvements to everyday life.",
15 ref_audio="PATH_TO_AUDIO",
16 ref_text="This is a sample reference transcript.",
17 cfg_scale=2.0,
18 sigma=0.25,
19 temperature=0.0,
20 max_tokens=200,
21 lang_code="en",
22 )
23)
24
25output = OUT / "en_01_tts_000.wav"
26audio_write(str(output), np.array(result.audio, dtype=np.float32), result.sample_rate, format="wav")
27print(output)ref_text when it exactly matches ref_audio. A mismatched transcript can collapse audio amplitude.1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --prompt "Please generate speech based on the following description.\n" \
4 --text "Simply put, this was equivalent to handing over the consumer market to competitors." \
5 --ref_audio "PATH_TO_AUDIO" \
6 --ref_text "This is a sample reference transcript." \
7 --instruct "Speak quickly, with medium pitch and higher volume." \
8 --cfg_scale 2.0 --sigma 0.25 --temperature 0.0 --max_tokens 200 \
9 --lang_code en \
10 --output_path "audio_io" \
11 --file_prefix en_02_basic \
12 --verbose1from pathlib import Path
2import numpy as np
3from mlx_audio.audio_io import write as audio_write
4from mlx_audio.tts.utils import load_model
5
6MODEL = "mlx-community/Ming-omni-tts-16.8B-A3B-bf16"
7OUT = Path("audio_io")
8OUT.mkdir(parents=True, exist_ok=True)
9
10model = load_model(MODEL)
11result = next(
12 model.generate(
13 prompt="Please generate speech based on the following description.\n",
14 text="Simply put, this was equivalent to handing over the consumer market to competitors.",
15 ref_audio="PATH_TO_AUDIO",
16 ref_text="This is a sample reference transcript.",
17 instruct="Speak quickly, with medium pitch and higher volume.",
18 cfg_scale=2.0,
19 sigma=0.25,
20 temperature=0.0,
21 max_tokens=200,
22 lang_code="en",
23 )
24)
25
26output = OUT / "en_02_basic_000.wav"
27audio_write(str(output), np.array(result.audio, dtype=np.float32), result.sample_rate, format="wav")
28print(output)1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --prompt "Please generate speech based on the following description.\n" \
4 --text "I got concert tickets at last! This is amazing. I cannot wait to hear the singer live on stage." \
5 --ref_audio "PATH_TO_AUDIO" \
6 --ref_text "This is a sample reference transcript." \
7 --instruct "Use a happy and excited tone." \
8 --cfg_scale 2.0 --sigma 0.25 --temperature 0.0 --max_tokens 200 \
9 --lang_code en \
10 --output_path "audio_io" \
11 --file_prefix en_03_emotion \
12 --verbose1from pathlib import Path
2import numpy as np
3from mlx_audio.audio_io import write as audio_write
4from mlx_audio.tts.utils import load_model
5
6MODEL = "mlx-community/Ming-omni-tts-16.8B-A3B-bf16"
7OUT = Path("audio_io")
8OUT.mkdir(parents=True, exist_ok=True)
9
10model = load_model(MODEL)
11result = next(
12 model.generate(
13 prompt="Please generate speech based on the following description.\n",
14 text="I got concert tickets at last! This is amazing. I cannot wait to hear the singer live on stage.",
15 ref_audio="PATH_TO_AUDIO",
16 ref_text="This is a sample reference transcript.",
17 instruct="Use a happy and excited tone.",
18 cfg_scale=2.0,
19 sigma=0.25,
20 temperature=0.0,
21 max_tokens=200,
22 lang_code="en",
23 )
24)
25
26output = OUT / "en_03_emotion_000.wav"
27audio_write(str(output), np.array(result.audio, dtype=np.float32), result.sample_rate, format="wav")
28print(output)1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --prompt "Please generate speech based on the following description.\n" \
4 --text "I believe both companies and individuals share this responsibility." \
5 --ref_audio "PATH_TO_AUDIO" \
6 --ref_text "This is a sample reference transcript." \
7 --instruct "Speak English with a Cantonese accent." \
8 --cfg_scale 2.0 --sigma 0.25 --temperature 0.0 --max_tokens 200 \
9 --lang_code en \
10 --output_path "audio_io" \
11 --file_prefix en_04_dialect \
12 --verbose1from pathlib import Path
2import numpy as np
3from mlx_audio.audio_io import write as audio_write
4from mlx_audio.tts.utils import load_model
5
6MODEL = "mlx-community/Ming-omni-tts-16.8B-A3B-bf16"
7OUT = Path("audio_io")
8OUT.mkdir(parents=True, exist_ok=True)
9
10model = load_model(MODEL)
11result = next(
12 model.generate(
13 prompt="Please generate speech based on the following description.\n",
14 text="I believe both companies and individuals share this responsibility.",
15 ref_audio="PATH_TO_AUDIO",
16 ref_text="This is a sample reference transcript.",
17 instruct="Speak English with a Cantonese accent.",
18 cfg_scale=2.0,
19 sigma=0.25,
20 temperature=0.0,
21 max_tokens=200,
22 lang_code="en",
23 )
24)
25
26output = OUT / "en_04_dialect_000.wav"
27audio_write(str(output), np.array(result.audio, dtype=np.float32), result.sample_rate, format="wav")
28print(output)--ref_audio, so merge the two prompt clips first:1uv run python - <<'PY'
2from pathlib import Path
3import numpy as np
4from mlx_audio.audio_io import write as audio_write
5from mlx_audio.utils import load_audio
6
7audio_a = "/Users/prince_canuma/Documents/mlx-audio-dev/Ming-omni-tts/data/wavs/CTS-CN-F2F-2019-11-11-423-012-A.wav"
8audio_b = "/Users/prince_canuma/Documents/mlx-audio-dev/Ming-omni-tts/data/wavs/CTS-CN-F2F-2019-11-11-423-012-B.wav"
9out = Path("./audio_io/cookbook_cli_en/ref_podcast_concat.wav")
10out.parent.mkdir(parents=True, exist_ok=True)
11sample_rate = 44100
12
13a = np.array(load_audio(audio_a, sample_rate=sample_rate), dtype=np.float32).reshape(-1)
14b = np.array(load_audio(audio_b, sample_rate=sample_rate), dtype=np.float32).reshape(-1)
15audio_write(str(out), np.concatenate([a, b], axis=0), sample_rate, format="wav")
16print(out)
17PY1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --prompt "Please generate speech based on the following description.\n" \
4 --text $' speaker_1:Could you summarize it again? I am not even sure whether I watched that movie.\n speaker_2:It is the one that turns into a funny classroom situation.\n speaker_1:Right.\n speaker_2:Yes, it is a comedy film.\n speaker_1:A comedy, got it.\n' \
5 --ref_audio "PATH_TO_AUDIO" \
6 --ref_text $' speaker_1:We still had monthly assessments, and even written exams for service jobs.\n speaker_2:Exactly, that is strange. Sometimes pay is low and rules are strict just because the brand is famous.\n' \
7 --cfg_scale 2.0 --sigma 0.25 --temperature 0.0 --max_tokens 200 \
8 --lang_code en \
9 --output_path "audio_io" \
10 --file_prefix en_05_podcast \
11 --verbose1from pathlib import Path
2import numpy as np
3from mlx_audio.audio_io import write as audio_write
4from mlx_audio.tts.utils import load_model
5from mlx_audio.utils import load_audio
6
7MODEL = "mlx-community/Ming-omni-tts-16.8B-A3B-bf16"
8AUDIO_A = "/Users/prince_canuma/Documents/mlx-audio-dev/Ming-omni-tts/data/wavs/CTS-CN-F2F-2019-11-11-423-012-A.wav"
9AUDIO_B = "/Users/prince_canuma/Documents/mlx-audio-dev/Ming-omni-tts/data/wavs/CTS-CN-F2F-2019-11-11-423-012-B.wav"
10OUT = Path("audio_io")
11OUT.mkdir(parents=True, exist_ok=True)
12REF_MERGED = OUT / "ref_podcast_concat.wav"
13
14model = load_model(MODEL)
15a = np.array(load_audio(AUDIO_A, sample_rate=model.sample_rate), dtype=np.float32).reshape(-1)
16b = np.array(load_audio(AUDIO_B, sample_rate=model.sample_rate), dtype=np.float32).reshape(-1)
17audio_write(str(REF_MERGED), np.concatenate([a, b], axis=0), model.sample_rate, format="wav")
18
19result = next(
20 model.generate(
21 prompt="Please generate speech based on the following description.\n",
22 text=(
23 " speaker_1:Could you summarize it again? I am not even sure whether I watched that movie.\n"
24 " speaker_2:It is the one that turns into a funny classroom situation.\n"
25 " speaker_1:Right.\n"
26 " speaker_2:Yes, it is a comedy film.\n"
27 " speaker_1:A comedy, got it.\n"
28 ),
29 ref_audio=str(REF_MERGED),
30 ref_text=(
31 " speaker_1:We still had monthly assessments, and even written exams for service jobs.\n"
32 " speaker_2:Exactly, that is strange. Sometimes pay is low and rules are strict just because the brand is famous.\n"
33 ),
34 cfg_scale=2.0,
35 sigma=0.25,
36 temperature=0.0,
37 max_tokens=200,
38 lang_code="en",
39 )
40)
41
42output = OUT / "en_05_podcast_000.wav"
43audio_write(str(output), np.array(result.audio, dtype=np.float32), result.sample_rate, format="wav")
44print(output)1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --prompt "Please generate speech based on the following description.\n" \
4 --text "The product name is Ultra Spicy Beef Balls." \
5 --instruct "Use a playful mascot brand spokesperson voice." \
6 --use_zero_spk_emb \
7 --cfg_scale 2.0 --sigma 0.25 --temperature 0.0 --max_tokens 200 \
8 --lang_code en \
9 --output_path "audio_io" \
10 --file_prefix en_06_ip \
11 --verbose1from pathlib import Path
2import numpy as np
3from mlx_audio.audio_io import write as audio_write
4from mlx_audio.tts.utils import load_model
5
6MODEL = "mlx-community/Ming-omni-tts-16.8B-A3B-bf16"
7OUT = Path("audio_io")
8OUT.mkdir(parents=True, exist_ok=True)
9
10model = load_model(MODEL)
11result = next(
12 model.generate(
13 prompt="Please generate speech based on the following description.\n",
14 text="The product name is Ultra Spicy Beef Balls.",
15 instruct="Use a playful mascot brand spokesperson voice.",
16 use_zero_spk_emb=True,
17 cfg_scale=2.0,
18 sigma=0.25,
19 temperature=0.0,
20 max_tokens=200,
21 lang_code="en",
22 )
23)
24
25output = OUT / "en_06_ip_000.wav"
26audio_write(str(output), np.array(result.audio, dtype=np.float32), result.sample_rate, format="wav")
27print(output)1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --prompt "Please generate speech based on the following description.\n" \
4 --text "I will stay with you here until you slowly drift into the softest and calmest sleep." \
5 --instruct "Use a soft ASMR whisper style, very gentle, very low volume, and very slow pace." \
6 --use_zero_spk_emb \
7 --cfg_scale 2.0 --sigma 0.25 --temperature 0.0 --max_tokens 200 \
8 --lang_code en \
9 --output_path "audio_io" \
10 --file_prefix en_07_style \
11 --verbose1from pathlib import Path
2import numpy as np
3from mlx_audio.audio_io import write as audio_write
4from mlx_audio.tts.utils import load_model
5
6MODEL = "mlx-community/Ming-omni-tts-16.8B-A3B-bf16"
7OUT = Path("audio_io")
8OUT.mkdir(parents=True, exist_ok=True)
9
10model = load_model(MODEL)
11result = next(
12 model.generate(
13 prompt="Please generate speech based on the following description.\n",
14 text="I will stay with you here until you slowly drift into the softest and calmest sleep.",
15 instruct="Use a soft ASMR whisper style, very gentle, very low volume, and very slow pace.",
16 use_zero_spk_emb=True,
17 cfg_scale=2.0,
18 sigma=0.25,
19 temperature=0.0,
20 max_tokens=200,
21 lang_code="en",
22 )
23)
24
25output = OUT / "en_07_style_000.wav"
26audio_write(str(output), np.array(result.audio, dtype=np.float32), result.sample_rate, format="wav")
27print(output)1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --prompt "Please generate audio events based on given text.\n" \
4 --text "Thunder and a gentle rain" \
5 --cfg_scale 4.5 --sigma 0.3 --temperature 2.5 --max_tokens 200 \
6 --lang_code en \
7 --output_path "audio_io" \
8 --file_prefix en_08_tta \
9 --verbose1from pathlib import Path
2import numpy as np
3from mlx_audio.audio_io import write as audio_write
4from mlx_audio.tts.utils import load_model
5
6MODEL = "mlx-community/Ming-omni-tts-16.8B-A3B-bf16"
7OUT = Path("audio_io")
8OUT.mkdir(parents=True, exist_ok=True)
9
10model = load_model(MODEL)
11result = next(
12 model.generate(
13 prompt="Please generate audio events based on given text.\n",
14 text="Thunder and a gentle rain",
15 cfg_scale=4.5,
16 sigma=0.3,
17 temperature=2.5,
18 max_tokens=200,
19 lang_code="en",
20 )
21)
22
23output = OUT / "en_08_tta_000.wav"
24audio_write(str(output), np.array(result.audio, dtype=np.float32), result.sample_rate, format="wav")
25print(output)1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --prompt "Please generate music based on the following description.\n" \
4 --text "Genre: electronic dance music. Mood: confident and determined. Instrument: drum kit. Theme: festival. Duration: 30 seconds." \
5 --cfg_scale 2.0 --sigma 0.25 --temperature 0.0 --max_tokens 400 \
6 --lang_code en \
7 --output_path "audio_io" \
8 --file_prefix en_09_bgm \
9 --verbose1from pathlib import Path
2import numpy as np
3from mlx_audio.audio_io import write as audio_write
4from mlx_audio.tts.utils import load_model
5
6MODEL = "mlx-community/Ming-omni-tts-16.8B-A3B-bf16"
7OUT = Path("audio_io")
8OUT.mkdir(parents=True, exist_ok=True)
9
10model = load_model(MODEL)
11result = next(
12 model.generate(
13 prompt="Please generate music based on the following description.\n",
14 text="Genre: electronic dance music. Mood: confident and determined. Instrument: drum kit. Theme: festival. Duration: 30 seconds.",
15 cfg_scale=2.0,
16 sigma=0.25,
17 temperature=0.0,
18 max_tokens=400,
19 lang_code="en",
20 )
21)
22
23output = OUT / "en_09_bgm_000.wav"
24audio_write(str(output), np.array(result.audio, dtype=np.float32), result.sample_rate, format="wav")
25print(output)1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --prompt "Please generate speech based on the following description.\n" \
4 --text "The performance decline can largely be attributed to stopping service for several brands." \
5 --ref_audio "PATH_TO_AUDIO" \
6 --ref_text "The performance decline can largely be attributed to stopping service for several brands." \
7 --instruct "Add warm contemporary classical background music with electric guitar and a festive mood at moderate SNR." \
8 --cfg_scale 2.0 --sigma 0.25 --temperature 0.0 --max_tokens 200 \
9 --lang_code en \
10 --output_path "audio_io" \
11 --file_prefix en_10_speech_bgm \
12 --verbose1from pathlib import Path
2import numpy as np
3from mlx_audio.audio_io import write as audio_write
4from mlx_audio.tts.utils import load_model
5
6MODEL = "mlx-community/Ming-omni-tts-16.8B-A3B-bf16"
7OUT = Path("audio_io")
8OUT.mkdir(parents=True, exist_ok=True)
9
10model = load_model(MODEL)
11result = next(
12 model.generate(
13 prompt="Please generate speech based on the following description.\n",
14 text="The performance decline can largely be attributed to stopping service for several brands.",
15 ref_audio="PATH_TO_AUDIO",
16 ref_text="The performance decline can largely be attributed to stopping service for several brands.",
17 instruct="Add warm contemporary classical background music with electric guitar and a festive mood at moderate SNR.",
18 cfg_scale=2.0,
19 sigma=0.25,
20 temperature=0.0,
21 max_tokens=200,
22 lang_code="en",
23 )
24)
25
26output = OUT / "en_10_speech_bgm_000.wav"
27audio_write(str(output), np.array(result.audio, dtype=np.float32), result.sample_rate, format="wav")
28print(output)1uv run mlx_audio.tts.generate \
2 --model "mlx-community/Ming-omni-tts-16.8B-A3B-bf16" \
3 --prompt "Please generate speech based on the following description.\n" \
4 --text "The performance decline can largely be attributed to stopping service for several brands." \
5 --ref_audio "PATH_TO_AUDIO" \
6 --ref_text "The performance decline can largely be attributed to stopping service for several brands." \
7 --instruct "Add birds chirping as a soft environmental background at moderate SNR." \
8 --cfg_scale 2.0 --sigma 0.25 --temperature 0.0 --max_tokens 200 \
9 --lang_code en \
10 --output_path "audio_io" \
11 --file_prefix en_11_speech_sound \
12 --verbose1from pathlib import Path
2import numpy as np
3from mlx_audio.audio_io import write as audio_write
4from mlx_audio.tts.utils import load_model
5
6MODEL = "mlx-community/Ming-omni-tts-16.8B-A3B-bf16"
7OUT = Path("audio_io")
8OUT.mkdir(parents=True, exist_ok=True)
9
10model = load_model(MODEL)
11result = next(
12 model.generate(
13 prompt="Please generate speech based on the following description.\n",
14 text="The performance decline can largely be attributed to stopping service for several brands.",
15 ref_audio="PATH_TO_AUDIO",
16 ref_text="The performance decline can largely be attributed to stopping service for several brands.",
17 instruct="Add birds chirping as a soft environmental background at moderate SNR.",
18 cfg_scale=2.0,
19 sigma=0.25,
20 temperature=0.0,
21 max_tokens=200,
22 lang_code="en",
23 )
24)
25
26output = OUT / "en_11_speech_sound_000.wav"
27audio_write(str(output), np.array(result.audio, dtype=np.float32), result.sample_rate, format="wav")
28print(output)