WebSocket Integration
VRCT provides a WebSocket server that allows external applications to receive real-time transcription and translation data. This enables integration with various third-party tools and custom applications.
Overviewβ
VRCT's WebSocket server broadcasts transcription and translation results to connected clients in real-time. This is particularly useful for:
- Text-to-Speech (TTS) Applications: Applications like VRCT-TTS that convert transcribed text to speech using VOICEVOX or gTTS
- Custom Overlays: Building custom overlay displays for streaming or recording
- External Monitoring: Monitoring transcription results from other applications
- Integration with Other Tools: Connecting VRCT to your own scripts or applications
Connection Detailsβ
The WebSocket server runs on the following default settings:
- Address:
127.0.0.1(localhost) - Port:
2231 - Connection URL:
ws://127.0.0.1:2231
VRCT acts as the WebSocket server, and external applications connect as clients.
How to Enableβ
- Open VRCT
- Navigate to Config β Other Settings
- Enable the WebSocket Server option
- The server will start automatically and listen for client connections
Data Formatβ
When VRCT sends a message (transcription result), it broadcasts data in the following JSON format.
The language settings (src_languages and dst_languages) depend on your VRCT configuration. The example below shows translation from Japanese to English, Korean, and Chinese Simplified.
{
"type": "CHAT",
"src_languages": {
"1": {
"language": "Japanese",
"country": "Japan",
"enable": true
}
},
"dst_languages": {
"1": {
"language": "English",
"country": "United States",
"enable": true
},
"2": {
"language": "Korean",
"country": "South Korea",
"enable": true
},
"3": {
"language": "Chinese Simplified",
"country": "China",
"enable": true
}
},
"message": "γγγ«γ‘γ―",
"translation": ["Hello", "μλ
νμΈμ", "δ½ ε₯½"],
"transliteration": [[], [], []]
}
Field Descriptionsβ
| Field | Type | Description |
|---|---|---|
type | string | Message type. "CHAT" or "SENT" indicates a transcription/translation result |
src_languages | object | Source language details. Keys are language numbers, values are objects containing language name, country, and enable status (depends on VRCT configuration) |
dst_languages | object | Target language details. Multiple translation target languages can be configured (depends on VRCT configuration) |
message | string | Original transcribed text in the source language |
translation | array | Array of translated texts for each target language |
transliteration | array | Array of transliteration data for each translation (may be empty) |
Use Case: VRCT-TTSβ
VRCT-TTS is a companion application that connects to VRCT via WebSocket and provides text-to-speech functionality.
Workflow:
- You speak into your microphone
- VRCT performs voice recognition and transcribes your speech
- VRCT translates the transcribed text (if enabled)
- VRCT sends the data via WebSocket
- VRCT-TTS receives the data and generates speech using VOICEVOX or gTTS
- The synthesized voice is played back
This enables real-time voice translation in VRChat conversations.
Custom Integration Exampleβ
You can create your own client application to receive VRCT data. Here's a basic example in Python:
import asyncio
import websockets
import json
async def connect_to_vrct():
uri = "ws://127.0.0.1:2231"
async with websockets.connect(uri) as websocket:
print("Connected to VRCT WebSocket server")
while True:
message = await websocket.recv()
data = json.loads(message)
if data["type"] in ["CHAT", "SENT"]:
print(f"Original: {data['message']}")
print(f"Translations: {data['translation']}")
# Get source language
src_lang = list(data['src_languages'].values())[0]['language']
print(f"Source language: {src_lang}")
# Display translations for each target language
for idx, (key, lang_info) in enumerate(data['dst_languages'].items()):
if lang_info['enable']:
print(f"{lang_info['language']}: {data['translation'][idx]}")
asyncio.run(connect_to_vrct())
Troubleshootingβ
Cannot Connect to WebSocket Serverβ
- Verify that the WebSocket server is enabled in VRCT settings
- Check that no other application is using port 2231
- Ensure your firewall is not blocking the connection
- Confirm you're using the correct address and port (
ws://127.0.0.1:2231)
No Data Being Receivedβ
- Make sure VRCT is actively performing voice recognition
- Verify that transcription is working properly in VRCT
- Check that your client application is properly handling incoming messages