| #!/bin/bash |
|
|
| |
| |
|
|
| set -e |
|
|
| |
| MODEL_FILE="${MODEL_FILE:-saudi_msa_epoch455.onnx}" |
| CONFIG_FILE="${CONFIG_FILE:-saudi_msa_epoch455.onnx.json}" |
|
|
| |
| GREEN='\033[0;32m' |
| RED='\033[0;31m' |
| YELLOW='\033[1;33m' |
| NC='\033[0m' |
|
|
| |
| print_success() { |
| echo -e "${GREEN}✓${NC} $1" |
| } |
|
|
| print_error() { |
| echo -e "${RED}✗${NC} $1" |
| } |
|
|
| print_info() { |
| echo -e "${YELLOW}ℹ${NC} $1" |
| } |
|
|
| |
| if ! command -v piper &> /dev/null; then |
| print_error "piper command not found" |
| echo "" |
| echo "Please install piper-tts:" |
| echo " pip install piper-tts" |
| echo "" |
| echo "Or use the Python script:" |
| echo " python3 inference.py -t \"Arabic text\" -o output.wav" |
| exit 1 |
| fi |
|
|
| |
| if [ ! -f "$MODEL_FILE" ]; then |
| print_error "Model file not found: $MODEL_FILE" |
| echo "" |
| echo "Please download the model from:" |
| echo " https://huggingface.co/ISTNetworks/saudi-msa-piper" |
| exit 1 |
| fi |
|
|
| |
| if [ $# -eq 0 ]; then |
| echo "Usage: $0 \"Arabic text\" [output.wav]" |
| echo "" |
| echo "Examples:" |
| echo " $0 \"مرحبا بك\" output.wav" |
| echo " echo \"مرحبا بك\" | $0 - output.wav" |
| echo " cat text.txt | $0 - output.wav" |
| echo "" |
| echo "Environment variables:" |
| echo " MODEL_FILE - Path to ONNX model (default: saudi_msa_epoch455.onnx)" |
| echo " CONFIG_FILE - Path to config file (default: saudi_msa_epoch455.onnx.json)" |
| exit 1 |
| fi |
|
|
| TEXT="$1" |
| OUTPUT="${2:-output.wav}" |
|
|
| |
| if [ "$TEXT" = "-" ]; then |
| print_info "Reading text from stdin..." |
| TEXT=$(cat) |
| fi |
|
|
| |
| if [ -z "$TEXT" ]; then |
| print_error "No text provided" |
| exit 1 |
| fi |
|
|
| |
| print_info "Model: $MODEL_FILE" |
| print_info "Text: $TEXT" |
| print_info "Output: $OUTPUT" |
| echo "" |
|
|
| echo "$TEXT" | piper --model "$MODEL_FILE" --output_file "$OUTPUT" |
|
|
| if [ $? -eq 0 ]; then |
| print_success "Audio generated successfully: $OUTPUT" |
| |
| |
| if command -v file &> /dev/null; then |
| file "$OUTPUT" |
| fi |
| |
| |
| if command -v du &> /dev/null; then |
| SIZE=$(du -h "$OUTPUT" | cut -f1) |
| echo "File size: $SIZE" |
| fi |
| else |
| print_error "Failed to generate audio" |
| exit 1 |
| fi |
|
|