#!/bin/bash # Soprano TTS to RVC Pipeline Launcher # This script helps you set up and run the soprano->RVC pipeline set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" VENV_PATH="$SCRIPT_DIR/.venv" RVC_DIR="$SCRIPT_DIR/Retrieval-based-Voice-Conversion-WebUI" RVC_GUI="$RVC_DIR/gui_v1.py" SOPRANO_SCRIPT="$SCRIPT_DIR/soprano_to_virtual_sink.py" # Colors for output RED='\033[0;31m' GREEN='\033[0;32m' YELLOW='\033[1;33m' BLUE='\033[0;34m' NC='\033[0m' # No Color # Print colored output print_info() { echo -e "${BLUE}ℹ ${NC}$1" } print_success() { echo -e "${GREEN}✓${NC} $1" } print_warning() { echo -e "${YELLOW}⚠${NC} $1" } print_error() { echo -e "${RED}✗${NC} $1" } print_header() { echo "" echo -e "${BLUE}═══════════════════════════════════════════════════════════════════${NC}" echo -e "${BLUE} $1${NC}" echo -e "${BLUE}═══════════════════════════════════════════════════════════════════${NC}" echo "" } # Check prerequisites check_prerequisites() { print_header "Checking Prerequisites" # Check if virtual environment exists if [ ! -d "$VENV_PATH" ]; then print_error "Virtual environment not found at: $VENV_PATH" exit 1 fi print_success "Virtual environment found" # Check if RVC GUI exists if [ ! -f "$RVC_GUI" ]; then print_error "RVC GUI not found at: $RVC_GUI" exit 1 fi print_success "RVC GUI found" # Check if soprano script exists if [ ! -f "$SOPRANO_SCRIPT" ]; then print_error "Soprano script not found at: $SOPRANO_SCRIPT" exit 1 fi print_success "Soprano script found" # Check if pactl is available (PulseAudio) if ! command -v pactl &> /dev/null; then print_error "pactl (PulseAudio) not found. Please install PulseAudio." exit 1 fi print_success "PulseAudio found" } # Display usage instructions show_usage() { print_header "Soprano TTS to RVC Pipeline" echo "This script helps you run a text-to-speech pipeline where:" echo " 1. You type text into the Soprano TTS script" echo " 2. Soprano generates speech and outputs to a virtual sink" echo " 3. RVC reads from that virtual sink and applies voice conversion" echo " 4. RVC outputs the converted voice to your speakers/headphones" echo "" echo "Usage:" echo " $0 [option]" echo "" echo "Options:" echo " soprano - Start only the Soprano TTS virtual sink script" echo " rvc - Start only the RVC realtime GUI" echo " both - Start both in separate terminal windows (default)" echo " help - Show this help message" echo "" } # Start soprano script start_soprano() { print_header "Starting Soprano TTS Virtual Sink" print_info "Activating virtual environment..." source "$VENV_PATH/bin/activate" print_info "Starting soprano_to_virtual_sink.py..." print_info "This will create a virtual sink: soprano_to_rvc" echo "" python "$SOPRANO_SCRIPT" } # Start RVC GUI start_rvc() { print_header "Starting RVC Realtime GUI" print_info "Activating virtual environment..." source "$VENV_PATH/bin/activate" print_info "Changing to RVC directory..." cd "$RVC_DIR" print_info "Starting RVC GUI..." echo "" print_warning "IMPORTANT: In the RVC GUI, select 'soprano_to_rvc.monitor' as your INPUT device!" echo "" sleep 2 python "$RVC_GUI" } # Start both in separate terminals start_both() { print_header "Starting Both Components" print_info "This will open two terminal windows:" print_info " 1. Soprano TTS Virtual Sink (for text input)" print_info " 2. RVC Realtime GUI (for voice conversion)" echo "" # Detect terminal emulator TERMINAL="" if command -v gnome-terminal &> /dev/null; then TERMINAL="gnome-terminal" elif command -v konsole &> /dev/null; then TERMINAL="konsole" elif command -v xfce4-terminal &> /dev/null; then TERMINAL="xfce4-terminal" elif command -v alacritty &> /dev/null; then TERMINAL="alacritty" elif command -v kitty &> /dev/null; then TERMINAL="kitty" elif command -v xterm &> /dev/null; then TERMINAL="xterm" else print_error "No suitable terminal emulator found" print_info "Please start the components manually:" print_info " Terminal 1: $0 soprano" print_info " Terminal 2: $0 rvc" exit 1 fi print_success "Using terminal: $TERMINAL" # Start soprano in new terminal print_info "Starting Soprano TTS in new terminal..." case "$TERMINAL" in gnome-terminal) gnome-terminal -- bash -c "cd '$SCRIPT_DIR' && bash '$0' soprano; exec bash" & ;; konsole) konsole -e bash -c "cd '$SCRIPT_DIR' && bash '$0' soprano; exec bash" & ;; xfce4-terminal) xfce4-terminal -e "bash -c \"cd '$SCRIPT_DIR' && bash '$0' soprano; exec bash\"" & ;; alacritty) alacritty -e bash -c "cd '$SCRIPT_DIR' && bash '$0' soprano; exec bash" & ;; kitty) kitty bash -c "cd '$SCRIPT_DIR' && bash '$0' soprano; exec bash" & ;; xterm) xterm -e bash -c "cd '$SCRIPT_DIR' && bash '$0' soprano; exec bash" & ;; esac sleep 2 # Start RVC in new terminal print_info "Starting RVC GUI in new terminal..." case "$TERMINAL" in gnome-terminal) gnome-terminal -- bash -c "cd '$SCRIPT_DIR' && bash '$0' rvc; exec bash" & ;; konsole) konsole -e bash -c "cd '$SCRIPT_DIR' && bash '$0' rvc; exec bash" & ;; xfce4-terminal) xfce4-terminal -e "bash -c \"cd '$SCRIPT_DIR' && bash '$0' rvc; exec bash\"" & ;; alacritty) alacritty -e bash -c "cd '$SCRIPT_DIR' && bash '$0' rvc; exec bash" & ;; kitty) kitty bash -c "cd '$SCRIPT_DIR' && bash '$0' rvc; exec bash" & ;; xterm) xterm -e bash -c "cd '$SCRIPT_DIR' && bash '$0' rvc; exec bash" & ;; esac echo "" print_success "Both components started in separate terminals" echo "" print_header "Quick Setup Guide" echo "1. In the RVC GUI window:" echo " - Select your RVC model (.pth file)" echo " - Select the corresponding index file" echo " - Choose 'soprano_to_rvc.monitor' as INPUT device" echo " - Choose your speakers/headphones as OUTPUT device" echo " - Click 'Start Voice Conversion'" echo "" echo "2. In the Soprano TTS window:" echo " - Type any text you want to convert" echo " - Press Enter to generate and stream" echo "" echo "3. Listen to the RVC-converted output!" echo "" print_info "Press Ctrl+C in each terminal to stop" echo "" } # Main script main() { case "${1:-both}" in soprano) check_prerequisites start_soprano ;; rvc) check_prerequisites start_rvc ;; both) check_prerequisites start_both ;; help|--help|-h) show_usage ;; *) print_error "Unknown option: $1" show_usage exit 1 ;; esac } main "$@"