big update

This commit is contained in:
gpatruno
2026-04-22 22:42:36 +02:00
parent 68cf59ae75
commit 7b2135bfed
25 changed files with 2661 additions and 564 deletions
+104 -52
View File
@@ -1,73 +1,125 @@
# twitchBot-intelligent
a twitch bot that listens to and records the audio and translates it into text, analyzes it using a text chat bot and sends a response over the chat.
Bot Twitch qui enregistre laudio dun stream, le transcrit en texte, analyse le contenu avec une couche de type « chat IA » (ex. tgpt), et peut répondre dans le chat. Le dépôt inclut une **interface web** pour piloter les flux et les composants (enregistrement, sous-titres, génération, envoi de messages).
## Fonctionnalités principales
- Enregistrement audio du stream (via intégration avec [twitch-recordAudio](https://github.com/Foufure13/twitch-recordAudio)).
- Transcription / alignement temporel (workflow prévu avec [WhisperX](https://github.com/m-bain/whisperX)).
- Génération de réponses et stockage des générations (fichiers JSON sous `storage/`).
- Lecture et envoi sur le chat Twitch (OAuth, utilisateurs dans `config/user.json`).
- **Interaction chat (mentions)** : si un viewer mentionne un des comptes enregistrés (ex: `@exoticnaturees`), le bot peut répondre automatiquement via **réponses préenregistrées** et **règles conditionnelles** (page “Interaction chat”).
- **Interface web** (Flask + Socket.IO) : gestion des flux, toggles IA / contrôle Twitch, sous-titres automatiques, etc.
Larchitecture détaillée des routes et composants est décrite dans [README_ARCHITECTURE.md](README_ARCHITECTURE.md). Linterface utilisateur côté navigateur est décrite dans [README_WEB_INTERFACE.md](README_WEB_INTERFACE.md).
## Structure du dépôt
| Élément | Rôle |
|--------|------|
| `start_web_interface.py` | Point dentrée recommandé : vérifie dépendances, config, lance le serveur. |
| `web_interface.py` | Application Flask : routes HTTP, Socket.IO, boucles auto (sous-titres / messages). |
| `twitch_bot/` | Logique métier isolée : `controller.py` (orchestration des flux et bots), `chat_state.py` (drapeau denvoi des messages). |
| `fonction/` | Classes principales du bot (`first_class.py`, `second_fonction.py`). |
| `config/` | `config.json` (paramètres généraux), `user.json` (comptes / tokens Twitch). |
| `storage/` | Données JSON (sous-titres, générations IA, etc.). |
| `static/`, `templates/` | Frontend de linterface web. |
| `main_auto_loop.py` | Mode terminal : boucle clavier pour enregistrement / IA sans passer par le web. |
| `debug/` | Scripts et essais de debug (hors chemin nominal). |
## Prérequis
- **Python 3.10+** (le projet a été utilisé avec 3.10 ; adaptez le venv si vous changez de version).
- Comptes / tokens Twitch configurés pour le chat et lAPI selon votre usage.
- Pour la transcription GPU : CUDA / cuDNN si vous utilisez Whisper côté machine (ex. Arch : `sudo pacman -S cuda cudnn` — ajustez selon votre distribution).
## Installation
clone project
```bash
git clone https://github.com/Foufure13/twitchBot-intelligent.git
cd twitchBot-intelligent
python3 -m venv env
source env/bin/activate # Windows: env\Scripts\activate
pip install -r requirements.txt
```
Install my-project with pip venv
### Dépôts externes (selon votre pipeline)
- **Audio** : [twitch-recordAudio](https://github.com/Foufure13/twitch-recordAudio) — enregistrement du flux.
- **Transcription** : [WhisperX](https://github.com/m-bain/whisperX) — installation suivant la doc du projet (`python setup.py install` ou équivalent).
- **« Chat » texte en CLI** : [tgpt](https://github.com/aandrew-me/tgpt) — binaire ou méthode dappel attendue par votre configuration.
### Fichiers de configuration
Avant de lancer linterface, créez ou complétez au minimum :
- `config/config.json` — paramètres du bot (chemins, prompts, etc.).
- `config/user.json` — utilisateurs Twitch pour lenvoi des messages.
Le script `start_web_interface.py` vérifie la présence de ces fichiers et crée les dossiers `storage/`, `record/`, `in_record/` si besoin.
## Lancement
```bash
python3.10 -m venv env
source env/bin/activate
python start_web_interface.py
```
Linterface écoute par défaut sur **http://0.0.0.0:5000** (voir `start_web_interface.py`).
## Interaction chat (mentions @)
### Principe
- Si un message de chat contient une mention dun **compte enregistré** (défini dans `config/user.json`), par exemple `@exoticnaturees`,
alors le module “Interaction chat” peut répondre automatiquement en notifiant lauteur:
- par défaut: `@<auteur> salut`
- ou via une règle conditionnelle (ex: si `cammenbert` dit “etoile etoile”, répondre `@cammenbert filante`)
### Configuration
- La configuration se fait dans linterface web, onglet **Interaction chat**.
- Les données sont stockées sous `storage/` :
- `storage/interaction_chat_config.json`
- `storage/interaction_chat_log.json`
### Mode TGPT
- Le mode **TGPT** est disponible: il envoie le message du viewer à `tgpt` avec un **préprompt** (global ou par règle), puis renvoie la réponse.
Mode terminal sans interface web :
```bash
python main_auto_loop.py -twitchname NOM_DU_CANAL
```
(Consulter les options `-threads`, `-recordtime` dans le script.)
## Dépannage
### Réparer un environnement pip cassé
```bash
deactivate
rm -rf env
python3 -m venv env
source env/bin/activate
pip install -r requirements.txt
sudo pacman -S cuda cudnn
```
clone other projects
twitch-recordAudio for stream audio recording
whisperX for audio-to-text translation
```bash
git clone https://github.com/Foufure13/twitch-recordAudio
git clone https://github.com/m-bain/whisperX
cd whisperX
python setup.py install
python -c "import whisperx"
```
install bin tgpt
### Whisper / erreurs fréquentes
tgpt for text chat bot
- Discussion utile : [openai/whisper#1027](https://github.com/openai/whisper/discussions/1027).
- Sur Arch, si besoin : `sudo pacman -S python-openai-whisper`.
https://github.com/aandrew-me/tgpt
### Références communautaires (bots / chat Twitch)
## Error
- [Kichi779/Twitch-Chat-Bot](https://github.com/Kichi779/Twitch-Chat-Bot)
- [mark-rez/Twitch-Chat-Reader](https://github.com/mark-rez/Twitch-Chat-Reader)
- [twitchat.fr](https://twitchat.fr/)
To Repair pip
---
```bash
deactivate
rm -rf env
python -m venv env
source env/bin/activate
pip install -r requirements.txt
```
debug error see
https://github.com/openai/whisper/discussions/1027
si tout le reste ne suffit pas
sudo pacman -S python-openai-whisper
https://github.com/Kichi779/Twitch-Chat-Bot
https://github.com/mark-rez/Twitch-Chat-Reader
https://twitchat.fr/
Pour le comportement des toggles chat / sous-titres et correctifs récents, voir aussi les fichiers notes du dépôt (`CHAT_TOGGLE_README.md`, `TOGGLE_IMPROVEMENTS.md`, etc.) si présents.