Speech-to-Text service using gRPC and the Whisper model from Hugging Face's Transformers library. The service allows users to send audio data and receive transcribed text in response.
- gRPC-based communication for efficient data transfer.
- Utilizes the Whisper model for high-quality speech recognition.
- Includes a client for sending audio data and receiving transcriptions.
- Unit tests to ensure the functionality of the service.
- Python 3.10 or higher
-
Clone the Repository
git clone https://github.com/your-username/speech-to-text-service.git cd speech-to-text-service
-
Install Dependencies Make sure to install the required packages as mentioned above:
pip install -r requirements.txt pip install -r requirements-dev.txt
-
Install Pre-commit To install pre-commit, run:
pip install pre-commit
-
Environment Variables Create a
.env
file in the root directory and set the following variables for local environment:ENVIRONMENT=local PORT=50051
For non-local environments (development or production), set the following variables:
ENVIRONMENT=development # or production SSL_PRIVATE_KEY_PATH=<path-to-private-key> SSL_CERTIFICATE_CHAIN_PATH=<path-to-certificate-chain>
-
Run the gRPC Server Start the server by running:
python main.py
-
Run the Client In a separate terminal, run the client to send audio data:
python src/client/client.py
-
Run Pre-commit Hooks To ensure code quality, install and run pre-commit hooks:
pre-commit run --all-files
-
Code Formatting and Linting Use
ruff
for linting andblack
for code formatting:ruff check . black .
To run the unit tests, execute the following command:
python -m unittest discover -s src/tests
Place your test audio files in the data
directory. The client will look for test_audio.wav
by default.
Feel free to submit issues or pull requests. Contributions are welcome!
This project is licensed under the MIT License.