Add few changes

This commit is contained in:
2025-05-04 17:27:39 +02:00
parent a469496269
commit e3a76da156
2 changed files with 158 additions and 20 deletions

View File

@@ -28,7 +28,7 @@ Note that run is also the default recipe. So `make` works too.
The run recipe should take care of everything for you... enjoy!
## Running translation server
### Running translation server
To start translation server for subtitle translation, run:
@@ -37,13 +37,13 @@ To start translation server for subtitle translation, run:
You can keep it running through multiple `make run`'s.
The makefile will pre-install everything if needed.
## Cleaning up the mess
### Cleaning up the mess
If you wish to go back to a clean slate just run:
`make clean`
## Packing for production
### Packing for production
To make an archive `pythagoras.tar.xz` in project root simply run:
@@ -51,13 +51,21 @@ To make an archive `pythagoras.tar.xz` in project root simply run:
## Usage
To connect to the WebSocket for receiving subtitles and messages, simply use the `/ws` endpoint, for example like this:
To connect to the WebSocket for receiving subtitles, messages and commands, simply use the `/ws` endpoint, for example like this:
`
websocat ws://localhost:8000/ws
`
To push new subtitles onto the server, use the `/subtitles` endpoints. There are currently two different ones, and each produces different response type. Here are some examples:
### Subtitles
Here is a list of all subtitle types:
- `subtitle_en_submit_sentence`, `subtitle_cs_submit_sentence`, `subtitle_en_update_current`, `subtitle_cs_update_current`
To push new subtitles onto the server, use the `/subtitles/` endpoints. There are currently two different ones, and each produces different response type. When translation is enabled, each sentence submission yields two websocket messages, one in English and one in Czech. Here are some examples:
___
- The first is `/subtitles/update_current`, which serves the purpose of updating the current sentence as it comes. Here is an example:
@@ -65,36 +73,103 @@ To push new subtitles onto the server, use the `/subtitles` endpoints. There are
curl -X POST http://localhost:8000/subtitles/update_current -H "Content-Type: text/plain" -d 'I love pushing '
`
___
- The second is `/subtitles/submit_sentence`, which is used to submit the next finished sentence. Here is an example:
`
curl -X POST http://localhost:8000/subtitles/submit_sentence -H "Content-Type: text/plain" -d 'I love pushing sentences to servers!'
`
___
### Commands
Here is a list of all commands:
- `getselectedmessage`, `setlibretranslate`, `setautopolling`, `autopollingrate`, `playvideo`, `seekvideo`, `setscreen_main`, `setscreen_video`, `setscreen_idle`
To control the server using commands, use the `/control` endpoint, for example like this:
___
- Poll the peehaitchpea server for the latest message to display:
`
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "getselectedmessage"}'
`
___
- Change the state of the LibreTranslate translation module (active or deactivated):
`
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "setlibretranslate", "state": false}'
`
___
- Change the state of auto-polling:
`
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "setautopolling", "state": false}'
`
`
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "setautopolling", "state": true}'
`
___
- Set the polling rate to a value (in seconds):
`
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "autopollingrate", "rate": 10}'
`
`
## TODO
___
- Create a command for playing a video (the TED talk RMS likes to play at the beginning of his lecture)
- Tell the client to play a video, defined by the filename parameter:
`
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "playvideo", "filename": "stallman.webm}'
`
___
- Seek the currently played video to a timestamp (in seconds):
`
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "seekvideo", "timestamp": 420}'
`
___
- Set the screen of the client to the main view (subtitles and messages):
`
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "setscreen_main"}'
`
___
- Set the screen of the client to the video playback:
`
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "setscreen_video"}'
`
___
- Set the screen of the client to the idle screen (this is the default screen after startup of the app):
`
curl -X POST http://localhost:8000/control -H "Content-Type: application/json" -d '{"command": "setscreen_idle"}'
`
___
### Media
You can also request media from Pythagoras using the `/media/` endpoint, which will yield you the standard HTTP FileResponse, here is an example:
`
curl -X GET http://localhost:8000/media/stallman.webm
`