Files
audiobook/test_api_directly.py
Paul Bailey 706ada866c feat: modernize UI with gradient design, glass morphism, and enhanced visual appeal
- Add purple/indigo gradient background throughout app
- Implement glass morphism effects on all cards
- Add gradient buttons with smooth hover animations
- Integrate emoji icons for better visual communication
- Enhance typography with improved font stack
- Add loading spinners and smooth transitions
- Improve color scheme with modern purple/indigo palette
- Add glowing shadows and depth effects
- Maintain responsive design and touch-friendly interactions
2025-12-09 12:29:40 +00:00

87 lines
2.1 KiB
Python

#!/usr/bin/env python3
"""
Test the API directly with the full story to verify backend functionality.
"""
import requests
import json
# Read the full story
with open('Test Story.txt', 'r') as f:
story = f.read()
print(f"Story length: {len(story)} characters\n")
# Test 1: Role Detection
print("=" * 70)
print("TEST 1: Role Detection")
print("=" * 70)
response = requests.post(
'http://localhost:8002/api/tts/roles',
json={'text': story},
headers={'Content-Type': 'application/json'}
)
print(f"Status: {response.status_code}")
if response.status_code == 200:
roles_data = response.json()
roles = roles_data['roles']
print(f"✓ Detected {len(roles)} roles:")
for role in roles:
print(f" - {role['label']}")
else:
print(f"❌ Error: {response.text}")
exit(1)
print()
# Test 2: Audio Generation with Multiple Voices
print("=" * 70)
print("TEST 2: Audio Generation")
print("=" * 70)
# Assign different voices to each role
voice_map = {
'Lily': 'af_bella',
'Benny': 'am_adam',
'Sammy': 'am_michael',
'Narrator': 'af_sarah'
}
# Build roles array for API
roles_array = []
for role in roles:
role_id = role['id']
voice = voice_map.get(role_id, 'af_bella')
roles_array.append({'id': role_id, 'voice': voice})
print(f" {role_id} → {voice}")
print(f"\nGenerating audiobook...")
response = requests.post(
'http://localhost:8002/api/tts',
json={
'text': story,
'lang': 'a',
'roles': roles_array,
'speed': 1.0
},
headers={'Content-Type': 'application/json'}
)
print(f"Status: {response.status_code}")
if response.status_code == 200:
# Save the audio file
with open('test_output.wav', 'wb') as f:
f.write(response.content)
print(f"✓ Generated audiobook: {len(response.content)} bytes")
print(f"✓ Saved to: test_output.wav")
print("\nYou can now play test_output.wav to hear the multi-voice audiobook!")
else:
print(f"❌ Error: {response.text}")
exit(1)
print("\n" + "=" * 70)
print("SUCCESS! Backend is working correctly with full story.")
print("=" * 70)