CoolFace
Apppublic

ebitlogix/Parler_TTS_API

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
test_urdu_tts.sh106 linesDownload Raw Back to root
1#!/bin/bash2 3API_URL="https://ebitlogix-parler-tts-api.hf.space"4OUTPUT_DIR="tts_output"5 6mkdir -p "$OUTPUT_DIR"7 8echo "======================================================================"9echo "TTS API Test Suite - Urdu Text Generation"10echo "======================================================================"11echo ""12 13# Health check14echo "Testing API Health Check..."15response=$(curl -s "$API_URL/")16if echo "$response" | grep -q "ok"; then17    echo "✅ API is running"18    echo "   Response: $response"19else20    echo "❌ API is not responding"21    exit 122fi23 24echo ""25echo "======================================================================"26echo "Testing TTS Generation with Urdu Text"27echo "======================================================================"28echo ""29 30# Test cases: text|speaker|description31declare -a TESTS=(32    "سلام دنیا|Divya|Hello World"33    "مرحبا بك في تطبيق تحويل النص إلى كلام|Rani|Welcome to TTS App"34    "یہ ایک اردو متن ہے جو آواز میں تبدیل ہوگا|Rohit|This is Urdu text"35    "کتاب پڑھنا میرا پسندیدہ کام ہے|Aman|Reading books"36    "خوشامدید، یہ ایک خوبصورت دن ہے|Generic Female|Beautiful day"37    "ہمیں اپنے لیے بہتر مستقبل بنانی ہے|Generic Male|Build future"38)39 40successful=041failed=042count=043 44for test in "${TESTS[@]}"; do45    IFS='|' read -r text speaker description <<< "$test"46    ((count++))47 48    echo "[$count/${#TESTS[@]}] Testing: $description"49    echo "     Text: $text"50    echo "     Speaker: $speaker"51 52    # Create JSON payload53    json_payload=$(cat <<EOF54{55    "text": "$text",56    "speaker": "$speaker",57    "pitch": "Moderate",58    "rate": "Moderate",59    "temperature": 0.8,60    "do_sample": true61}62EOF63)64 65    # Make API request and save audio66    timestamp=$(date +%Y%m%d_%H%M%S)67    filename="${timestamp}_${speaker// /_}_${count}.wav"68    filepath="$OUTPUT_DIR/$filename"69 70    http_code=$(curl -s -w "%{http_code}" -o "$filepath" \71        -X POST "$API_URL/tts" \72        -H "Content-Type: application/json" \73        -d "$json_payload")74 75    if [ "$http_code" = "200" ]; then76        file_size=$(du -h "$filepath" | cut -f1)77        echo "     ✅ Success - Saved to: $filepath ($file_size)"78        ((successful++))79    else80        echo "     ❌ Failed - HTTP $http_code"81        rm -f "$filepath"82        ((failed++))83    fi84 85    echo ""86done87 88echo "======================================================================"89echo "Results: $successful successful, $failed failed"90echo "Audio files saved to: $(pwd)/$OUTPUT_DIR"91echo "======================================================================"92echo ""93 94# List generated files95if [ $successful -gt 0 ]; then96    echo "Generated files:"97    ls -lh "$OUTPUT_DIR" | tail -n +2 | awk '{print "  " $9, "(" $5 ")"}'98    echo ""99fi100 101if [ $failed -eq 0 ]; then102    echo "✅ All tests passed!"103else104    echo "⚠️  $failed test(s) failed."105fi106