Files
2026-06-03 00:34:42 +08:00

100 lines
2.8 KiB
Markdown

# Speaking Lab
Local first-version prototype for English speaking practice.
## Install
Install the backend dependencies when running the FastAPI server locally:
```powershell
python -m pip install fastapi uvicorn python-multipart
```
`python-multipart` is required because `POST /api/videos` uses FastAPI `Form` and `File` uploads.
## Run
```powershell
cd F:\ooo\speaking-practice-local
python -m uvicorn backend.main:app --reload --host 127.0.0.1 --port 8000
```
Open:
```text
http://127.0.0.1:8000
```
API docs:
```text
http://127.0.0.1:8000/docs
```
Admin page:
```text
http://127.0.0.1:8000/admin.html
```
## What works
- Local video library with tags and fuzzy keyword search.
- Basic login/register stored in browser localStorage.
- Admin mode when the email contains `admin`.
- Favorites and watch-later lists.
- Dedicated admin page for adding and deleting materials.
- Admin upload for local video files or video/HLS URLs.
- Admin upload for English and Chinese `.srt` / `.vtt` subtitles.
- Multilingual subtitle selectors.
- Bilingual subtitle display.
- Click transcript lines to jump the video to the matching timestamp.
- Current transcript line highlighting.
- Sentence replay, previous/next sentence, sentence loop.
- Browser microphone recording and local playback.
## Notes
- This first version is a local browser app, not a production server app.
- User login state, favorites, and watch-later lists are still stored in browser localStorage.
- Added content library videos and subtitles are persisted through the FastAPI backend.
- FastAPI initializes `backend/speaking_lab.sqlite` on startup.
## Content Library
The admin page saves videos and subtitles through the FastAPI backend.
Supported first-version flow:
- Log in with an email containing `admin`.
- Click the small `管理` button beside the `素材` heading, or open `/admin.html`.
- Add a title, speaker, description, and comma-separated tags.
- Choose either a local video file or a video/HLS URL.
- Optionally upload English and Chinese `.srt` / `.vtt` subtitle files.
- Delete materials from the admin page when you no longer want them.
- Refresh the browser and confirm the added video remains in the library.
Uploaded files are stored locally:
- Videos: `uploads/videos/`
- Subtitles: `uploads/subtitles/`
Metadata is stored in SQLite:
- `backend/speaking_lab.sqlite`
## Admin Page
Content management is handled on a separate local admin page:
```text
http://127.0.0.1:8000/admin.html
```
In this prototype, an admin is any local user whose email contains `admin`.
After logging in as an admin on the study page, a small `管理` button appears
beside the `素材` heading. The admin page supports adding and deleting
materials. Editing and subtitle replacement are planned for later.
This phase does not include web editing, real authentication, learning progress sync, or server deployment.