Apache & Production Deployment
Relevant source files
The following files were used as context for generating this wiki page:
The Wikispeech server is designed to operate within a distributed microservices architecture, often fronted by an Apache HTTP server in production environments. This setup allows for secure access to generated audio files, proxying of API requests to the Python Flask backend, and integration with various TTS engines like MaryTTS, Piper, and Matcha.
Deployment involves configuring Apache as a reverse proxy, setting up local directory structures for temporary audio storage, and ensuring all underlying microservices (lexicon, symbolset mapper, etc.) are correctly initialized and reachable.
Apache Proxy Configuration
To expose the Wikispeech server and its associated services through a standard web port (e.g., 80 or 443), Apache is configured using mod_proxy and mod_proxy_http. This configuration redirects external traffic to the local ports where the Flask application and other microservices reside.
Reverse Proxy Setup
Requests to specific URL paths are mapped to the internal services. For example, the main Wikispeech API typically runs on port 10000, while the lexicon service might run on port 8787.
ProxyPreserveHost On
ProxyPass /wikispeech/ http://127.0.1.1:10000/
ProxyPassReverse /wikispeech/ http://127.0.1.1:10000/
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /ws_service/ http://127.0.1.1:8787/
ProxyPassReverse /ws_service/ http://127.0.1.1:8787/
ProxyRequests Off
Sources: README.md:112-123
Audio File Accessibility
For production deployments, audio files generated by the TTS engines are stored in a temporary directory and served via a symbolic link in the Apache web root. This allows direct HTTP access to .opus files without overloading the Flask application.
- Create a symlink:
sudo ln -s <audio_tmpdir> /var/www/html/audio - Audio files become accessible at
http://<HOSTNAME>/audio
Sources: README.md:85-94
Production Architecture & Data Flow
The production environment relies on several interconnected services. The wikispeech.py script acts as the central coordinator, receiving text or SSML input and orchestrating calls to textprocessors and synthesis adapters.
The following diagram illustrates the request flow when Apache is used as the frontend:
This diagram shows how Apache manages both static asset delivery and dynamic API proxying to the microservice cluster.
Sources: README.md:112-123, start_wikispeech.sh:130-145, wikispeech_server/wikispeech.py:545-555
Server Configuration
Production settings are managed through .conf files. The system looks for these files to define port numbers, logging behavior, and service URLs.
Key Configuration Sections
| Section | Option | Description | Default/Example |
|---|---|---|---|
| Server | port | The port the Flask app listens on. | 10000 |
| Server | log_level | Severity of logs recorded. | info/warning |
| Audio settings | audio_tmpdir | Local path for sound files. | ./wikispeech_server/tmp |
| Services | lexicon | URL for the lexicon server. | http://localhost:8787 |
| Services | marytts | URL for MaryTTS processing. | http://localhost:59125/process |
Sources: README.md:38-58, wikispeech_server/default.conf:1-30
Security and Access Control
When serving audio files via Apache, it is recommended to restrict access to prevent unauthorized listing or access to non-audio system files.
.htaccess Protection
Within the <audio_tmpdir>, an .htaccess file can be used to allow only specific file types:
<FilesMatch "\.*$">
Deny from all
</FilesMatch>
<FilesMatch "\.opus$">
Order deny,allow
Allow from all
</FilesMatch>
Additionally, an empty or descriptive index.html should be placed in the audio directory to disable directory listing.
Sources: README.md:98-108
Deployment Orchestration
The project provides shell scripts to manage the lifecycle of the production environment.
Startup Sequence
The start_wikispeech.sh script automates the initialization of the service stack:
- Starts the
pronlex(lexicon) server. - Starts the
symbolsetmapper. - Initializes TTS wrappers (Matcha, Piper).
- Clears the audio cache using
clear_audio_cache.sh. - Starts the main Wikispeech Flask server using
nohupto keep it running in the background.
Sources: start_wikispeech.sh:125-155
Build and Test
Before production deployment, the build_and_test.sh script mimics a CI environment to ensure all components are functional. It kills existing processes, rebuilds binaries, and runs a series of startup tests.
Sources: build_and_test.sh:18-30
Conclusion
Production deployment of Wikispeech requires a coordinated configuration between the Apache web server and the internal microservices. By utilizing Apache's proxy capabilities and efficient static file serving, the system provides a scalable and secure interface for Text-to-Speech synthesis. Proper configuration of the .conf files and adherence to the recommended startup sequence ensures high availability of the synthesis services.