48 lines
1.4 KiB
Python
48 lines
1.4 KiB
Python
import os
|
|
import subprocess
|
|
import tempfile
|
|
|
|
|
|
def test_kokoro_tts():
|
|
"""Test that kokoro-tts works correctly"""
|
|
# Create temporary input file with some text
|
|
with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False) as f:
|
|
f.write("Hello world, this is a test of the kokoro TTS system.")
|
|
temp_file = f.name
|
|
|
|
try:
|
|
# Run kokoro-tts command
|
|
cmd = ["kokoro-tts", temp_file, "test_output.wav", "--voice", "bm_george"]
|
|
result = subprocess.run(cmd, check=True, capture_output=True, text=True)
|
|
|
|
print("Command executed successfully")
|
|
print(f"Return code: {result.returncode}")
|
|
print(f"Output: {result.stdout}")
|
|
print(f"Error: {result.stderr}")
|
|
|
|
# Check if output file was created
|
|
if os.path.exists("test_output.wav"):
|
|
print("Output file created successfully")
|
|
return True
|
|
else:
|
|
print("Output file was not created")
|
|
return False
|
|
|
|
except subprocess.CalledProcessError as e:
|
|
print(f"Command failed with return code {e.returncode}")
|
|
print(f"Error output: {e.stderr}")
|
|
return False
|
|
except Exception as e:
|
|
print(f"Unexpected error: {e}")
|
|
return False
|
|
finally:
|
|
# Clean up temporary file
|
|
try:
|
|
os.unlink(temp_file)
|
|
except:
|
|
pass
|
|
|
|
|
|
if __name__ == "__main__":
|
|
test_kokoro_tts()
|