Update to support sync captions
This commit is contained in:
160
server/test-server.sh
Executable file
160
server/test-server.sh
Executable file
@@ -0,0 +1,160 @@
|
||||
#!/bin/bash
|
||||
# Test script for multi-user transcription servers
|
||||
|
||||
set -e
|
||||
|
||||
echo "================================="
|
||||
echo "Multi-User Server Test Script"
|
||||
echo "================================="
|
||||
echo ""
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Get server URL from user
|
||||
echo "What server are you testing?"
|
||||
echo "1) PHP Server"
|
||||
echo "2) Node.js Server"
|
||||
echo "3) Custom URL"
|
||||
read -p "Choice (1-3): " choice
|
||||
|
||||
case $choice in
|
||||
1)
|
||||
read -p "Enter PHP server URL (e.g., https://example.com/transcription/server.php): " SERVER_URL
|
||||
API_ENDPOINT="${SERVER_URL}?action=send"
|
||||
;;
|
||||
2)
|
||||
read -p "Enter Node.js server URL (e.g., http://localhost:3000): " SERVER_URL
|
||||
API_ENDPOINT="${SERVER_URL}/api/send"
|
||||
;;
|
||||
3)
|
||||
read -p "Enter API endpoint URL: " API_ENDPOINT
|
||||
;;
|
||||
*)
|
||||
echo "Invalid choice"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Get room details
|
||||
read -p "Room name [test]: " ROOM
|
||||
ROOM=${ROOM:-test}
|
||||
|
||||
read -p "Passphrase [testpass]: " PASSPHRASE
|
||||
PASSPHRASE=${PASSPHRASE:-testpass}
|
||||
|
||||
read -p "User name [TestUser]: " USER_NAME
|
||||
USER_NAME=${USER_NAME:-TestUser}
|
||||
|
||||
echo ""
|
||||
echo "================================="
|
||||
echo "Testing connection to server..."
|
||||
echo "================================="
|
||||
echo "API Endpoint: $API_ENDPOINT"
|
||||
echo "Room: $ROOM"
|
||||
echo "User: $USER_NAME"
|
||||
echo ""
|
||||
|
||||
# Test 1: Send a transcription
|
||||
echo "Test 1: Sending test transcription..."
|
||||
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "$API_ENDPOINT" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"room\": \"$ROOM\",
|
||||
\"passphrase\": \"$PASSPHRASE\",
|
||||
\"user_name\": \"$USER_NAME\",
|
||||
\"text\": \"Test message from test script\",
|
||||
\"timestamp\": \"$(date +%H:%M:%S)\"
|
||||
}")
|
||||
|
||||
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
||||
BODY=$(echo "$RESPONSE" | sed '$d')
|
||||
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
echo -e "${GREEN}✓ Success!${NC} Server responded with 200 OK"
|
||||
echo "Response: $BODY"
|
||||
else
|
||||
echo -e "${RED}✗ Failed!${NC} Server responded with HTTP $HTTP_CODE"
|
||||
echo "Response: $BODY"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
# Test 2: Send multiple messages
|
||||
echo "Test 2: Sending 5 test messages..."
|
||||
for i in {1..5}; do
|
||||
curl -s -X POST "$API_ENDPOINT" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"room\": \"$ROOM\",
|
||||
\"passphrase\": \"$PASSPHRASE\",
|
||||
\"user_name\": \"$USER_NAME\",
|
||||
\"text\": \"Test message #$i\",
|
||||
\"timestamp\": \"$(date +%H:%M:%S)\"
|
||||
}" > /dev/null
|
||||
|
||||
echo -e "${GREEN}✓${NC} Sent message #$i"
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
echo ""
|
||||
|
||||
# Test 3: List transcriptions (if available)
|
||||
echo "Test 3: Retrieving transcriptions..."
|
||||
|
||||
if [ "$choice" = "1" ]; then
|
||||
LIST_URL="${SERVER_URL}?action=list&room=$ROOM"
|
||||
elif [ "$choice" = "2" ]; then
|
||||
LIST_URL="${SERVER_URL}/api/list?room=$ROOM"
|
||||
else
|
||||
echo "Skipping list test for custom URL"
|
||||
LIST_URL=""
|
||||
fi
|
||||
|
||||
if [ -n "$LIST_URL" ]; then
|
||||
LIST_RESPONSE=$(curl -s "$LIST_URL")
|
||||
COUNT=$(echo "$LIST_RESPONSE" | grep -o "\"text\"" | wc -l)
|
||||
|
||||
if [ "$COUNT" -gt 0 ]; then
|
||||
echo -e "${GREEN}✓ Success!${NC} Retrieved $COUNT transcriptions"
|
||||
echo "$LIST_RESPONSE" | python3 -m json.tool 2>/dev/null || echo "$LIST_RESPONSE"
|
||||
else
|
||||
echo -e "${YELLOW}⚠ Warning:${NC} No transcriptions retrieved"
|
||||
echo "$LIST_RESPONSE"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "================================="
|
||||
echo "Test Complete!"
|
||||
echo "================================="
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo ""
|
||||
|
||||
if [ "$choice" = "1" ]; then
|
||||
echo "1. Open this URL in OBS Browser Source:"
|
||||
echo " ${SERVER_URL%server.php}display-polling.php?room=$ROOM&fade=10"
|
||||
echo ""
|
||||
echo "2. Or test in your browser first:"
|
||||
echo " ${SERVER_URL%server.php}display-polling.php?room=$ROOM"
|
||||
elif [ "$choice" = "2" ]; then
|
||||
echo "1. Open this URL in OBS Browser Source:"
|
||||
echo " ${SERVER_URL}/display?room=$ROOM&fade=10"
|
||||
echo ""
|
||||
echo "2. Or test in your browser first:"
|
||||
echo " ${SERVER_URL}/display?room=$ROOM"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "3. Configure desktop app with these settings:"
|
||||
echo " - Server URL: $API_ENDPOINT"
|
||||
echo " - Room: $ROOM"
|
||||
echo " - Passphrase: $PASSPHRASE"
|
||||
echo ""
|
||||
echo "4. Start transcribing!"
|
||||
echo ""
|
||||
Reference in New Issue
Block a user