File size: 3,883 Bytes
27caffe
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
README.md

πŸ›‘οΈ Police Bot Runtime β€” AI Voice Assistant for Bengaluru Police
This is the runtime layer of an AI-powered mental wellness assistant built for frontline Bengaluru Police officers. The assistant runs locally and privately using an LLM (via Ollama) and a fine-tuned voice cloning TTS model (via XTTS/F5-TTS), producing empathetic voice replies in real-time based on officer input.

πŸ’¬ Text In β†’ πŸ€– LLM Reply β†’ πŸ—£οΈ Voice Cloned Output

πŸ“Œ Project Goals
Create a voice-first wellness chatbot for police personnel

Fully private, runs entirely offline on powerful local machines

Replies are generated by an open-source LLM (police-bot) via Ollama

Responses are spoken aloud using a fine-tuned XTTS voice cloned from a real speaker

Easily extendable to integrate into a React-based web interface later

Future support for Kannada via multi-lingual XTTS fine-tuning

🧠 System Overview
This repo powers the runtime experience.

Ollama runs an LLM (LLaMA 3, Mistral etc.) via the police-bot model

Python script police_runtime.py communicates with Ollama (localhost:11434)

LLM reply is sent to police_bot_voice.py

XTTS reads a voice reference and generates a realistic audio response (output.wav)

Audio is played back to the officer

Example flow:

Officer: I'm feeling low today
Assistant: [spoken aloud] Namaskara! I’m here to support you. You're a valued member of the force...

πŸ“‚ Folder Structure
Your folder layout should look like:

police-bot-runtime/
β”‚
β”œβ”€β”€ police_runtime.py # Main loop: user input β†’ LLM β†’ voice
β”œβ”€β”€ police_bot_voice.py # Loads XTTS model, speaks response
β”‚
β”œβ”€β”€ my_finetuned_model/ # XTTS fine-tuned model files
β”‚ β”œβ”€β”€ config.json
β”‚ β”œβ”€β”€ dvae.ptj
β”‚ β”œβ”€β”€ mel_stats.pth
β”‚ β”œβ”€β”€ model.pth
β”‚ └── vocab.json
β”‚
β”œβ”€β”€ datasets-1/
β”‚ └── wavs/
β”‚ └── 0029.wav # Reference voice clip used for inference
β”‚
β”œβ”€β”€ venv/ # Python virtual environment
└── requirements.txt # (Optional) Dependency list

βš™οΈ Setup Instructions
🧩 Prerequisites:

Windows 10/11, 64-bit

Python 3.11 (recommended)

Ollama installed: https://ollama.com

Trained XTTS voice model (via F5-TTS or Coqui)

Clone or copy this folder as police-bot-runtime

Create a virtual environment:

bash
Copy
Edit
python -m venv venv
venv\Scripts\activate
Install dependencies:

bash
Copy
Edit
pip install TTS requests
Start the Ollama LLM (separate terminal):

bash
Copy
Edit
ollama run police-bot
Run the voice assistant:

bash
Copy
Edit
python police_runtime.py
You'll be prompted for input. Replies will be printed and voiced out.

πŸ§ͺ Testing Voice Model
Your test_voice.py should look like:

python
Copy
Edit
from TTS.api import TTS

tts = TTS(
    model_path="my_finetuned_model/",
    config_path="my_finetuned_model/config.json",
    gpu=True
)

tts.tts_to_file(
    text="Hey officer, everything okay?",
    file_path="output.wav",
    speaker_wav="datasets-1/wavs/0029.wav",
    language="en"
)
🧠 How It Works
Ollama LLM (LLaMA3) is launched with ollama run police-bot

Text prompt is sent to http://localhost:11434/api/generate

Response is sent to XTTS model for synthesis

XTTS clones voice using speaker_wav file

Audio saved to output.wav and played using playsound or equivalent

πŸ› οΈ Future Enhancements
 Integrate directly with the frontend (React + ShadCN + Web Speech API)

 Support both English and Kannada voice cloning

 Add emotional sentiment analysis (LLaMA + classifier)

 Handle stress journaling and daily wellness logging

 Auto-log sessions to Supabase or local DB

 Deploy offline on a rugged laptop for field use

πŸ™ Acknowledgements
Voice cloning: F5-TTS / Coqui XTTS

LLM inference: Ollama + LLaMA3 8B

Frontend inspiration: GovSchemes project

This is a labor of respect and service. Designed to support those who protect us.

β€”