50 lines
1.7 KiB
Python
50 lines
1.7 KiB
Python
#!/usr/bin/env python3
|
|
"""Test TTS on G1 built-in speaker — Arabic, English, Chinese."""
|
|
|
|
import sys
|
|
import time
|
|
from unitree_sdk2py.core.channel import ChannelFactoryInitialize
|
|
from unitree_sdk2py.g1.audio.g1_audio_client import AudioClient
|
|
|
|
if len(sys.argv) < 2:
|
|
print(f"Usage: python3 {sys.argv[0]} <network_interface>")
|
|
print(f" e.g. python3 {sys.argv[0]} eth0")
|
|
sys.exit(1)
|
|
|
|
ChannelFactoryInitialize(0, sys.argv[1])
|
|
c = AudioClient()
|
|
c.SetTimeout(10.0)
|
|
c.Init()
|
|
c.SetVolume(100)
|
|
|
|
tests = [
|
|
("English", 0, "Hello, I am the Unitree G1 robot. Welcome to Lootah."),
|
|
("English", 0, "How are you today? I hope you are doing well."),
|
|
("Chinese", 0, "你好,我是宇树科技的人形机器人。欢迎光临。"),
|
|
("Arabic", 0, "مرحبا، أنا الروبوت يونيتري جي وان. أهلا وسهلا بكم."),
|
|
("Arabic", 0, "كيف حالك اليوم؟ أتمنى أن تكون بخير."),
|
|
("English", 0, "Testing numbers: one, two, three, four, five."),
|
|
("Arabic", 0, "واحد، اثنان، ثلاثة، أربعة، خمسة."),
|
|
]
|
|
|
|
for lang, speaker_id, text in tests:
|
|
print(f"\n[{lang}] speaker_id={speaker_id}")
|
|
print(f" Text: {text}")
|
|
code = c.TtsMaker(text, speaker_id)
|
|
print(f" Return code: {code}")
|
|
# Wait proportional to text length
|
|
wait = max(3, len(text) * 0.08)
|
|
print(f" Waiting {wait:.1f}s...")
|
|
time.sleep(wait)
|
|
|
|
# Try different speaker IDs for English
|
|
print("\n--- Testing different speaker IDs ---")
|
|
for sid in [0, 1, 2]:
|
|
text = "Hello, testing speaker ID."
|
|
print(f"\n speaker_id={sid}: '{text}'")
|
|
code = c.TtsMaker(text, sid)
|
|
print(f" code={code}")
|
|
time.sleep(4)
|
|
|
|
print("\nDone. Which languages did you hear?")
|