marcosremar2 commited on
Commit
a80c875
·
1 Parent(s): c014bac

Add UFPAlign Docker implementation - Fix MFA Portuguese model names in original Dockerfile - Add comprehensive UFPAlign Docker setup with Kaldi toolkit - Include Docker Compose configuration for multi-container deployment - Add Makefile with convenient commands for container management - Support for interactive shell, API service, and batch processing - Complete documentation for UFPAlign Brazilian Portuguese alignment

Browse files
Dockerfile CHANGED
@@ -17,7 +17,7 @@ RUN pip install --no-cache-dir \
17
  WORKDIR /app
18
 
19
  # Download Portuguese models during build
20
- RUN mfa model download acoustic portuguese_brazil_mfa && \
21
  mfa model download g2p portuguese_brazil_mfa
22
 
23
  # Copy application files
 
17
  WORKDIR /app
18
 
19
  # Download Portuguese models during build
20
+ RUN mfa model download acoustic portuguese_mfa && \
21
  mfa model download g2p portuguese_brazil_mfa
22
 
23
  # Copy application files
Dockerfile.ufpalign ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM kaldiasr/kaldi:latest
2
+
3
+ LABEL maintainer="UFPAlign Docker Implementation"
4
+ LABEL description="UFPAlign - Brazilian Portuguese Forced Phonetic Alignment Tool"
5
+ LABEL version="1.0"
6
+
7
+ # Set environment variables
8
+ ENV UFPALIGN_DIR=/opt/UFPAlign
9
+ ENV KALDI_ROOT=/opt/kaldi
10
+ ENV LC_ALL=pt_BR.UTF-8
11
+ ENV LANG=pt_BR.UTF-8
12
+ ENV PYTHONPATH=/opt/UFPAlign:$PYTHONPATH
13
+
14
+ # Update system and install dependencies
15
+ RUN apt-get update && \
16
+ apt-get install -y --no-install-recommends \
17
+ sudo \
18
+ curl \
19
+ wget \
20
+ openjdk-8-jdk \
21
+ locales \
22
+ python3-pip \
23
+ python3-dev \
24
+ python3-setuptools \
25
+ build-essential \
26
+ sox \
27
+ ffmpeg \
28
+ git && \
29
+ # Configure locale for Portuguese (Brazil)
30
+ sed -i '/pt_BR.UTF-8/s/^# //g' /etc/locale.gen && \
31
+ locale-gen && \
32
+ # Upgrade pip
33
+ pip3 install --upgrade pip && \
34
+ # Create UFPAlign directory
35
+ mkdir -p $UFPALIGN_DIR && \
36
+ # Clean up apt cache
37
+ apt-get clean && \
38
+ rm -rf /var/lib/apt/lists/*
39
+
40
+ # Install Python dependencies
41
+ RUN pip3 install --no-cache-dir \
42
+ gdown==5.0.0 \
43
+ numpy==1.26.3 \
44
+ pandas==2.2.2 \
45
+ TextGrid==1.5 \
46
+ Unidecode==1.3.8 \
47
+ fastapi \
48
+ uvicorn \
49
+ python-multipart \
50
+ pydantic \
51
+ aiofiles
52
+
53
+ # Clone UFPAlign repository
54
+ RUN cd /opt && \
55
+ git clone https://github.com/falabrasil/ufpalign.git UFPAlign && \
56
+ cd UFPAlign && \
57
+ chmod +x ufpalign.sh
58
+
59
+ # Set working directory
60
+ WORKDIR $UFPALIGN_DIR
61
+
62
+ # Copy application files if they exist in build context
63
+ COPY app.py /opt/UFPAlign/ 2>/dev/null || true
64
+ COPY requirements.txt /opt/UFPAlign/ 2>/dev/null || true
65
+
66
+ # Create necessary directories
67
+ RUN mkdir -p \
68
+ $UFPALIGN_DIR/uploads \
69
+ $UFPALIGN_DIR/output \
70
+ $UFPALIGN_DIR/textgrid \
71
+ /root/logs
72
+
73
+ # Download models during build (optional - can be done at runtime)
74
+ # RUN utils/download_model.sh "data" $UFPALIGN_DIR && \
75
+ # utils/download_model.sh "mono" $UFPALIGN_DIR
76
+
77
+ # Make sure Kaldi is properly linked
78
+ RUN if [ -d "/opt/kaldi" ]; then \
79
+ ln -sf /opt/kaldi/egs/wsj/s5/steps $UFPALIGN_DIR/steps; \
80
+ ln -sf /opt/kaldi/egs/wsj/s5/utils $UFPALIGN_DIR/utils_kaldi; \
81
+ ln -sf /opt/kaldi/egs/wsj/s5/path.sh $UFPALIGN_DIR/path.sh; \
82
+ fi
83
+
84
+ # Set proper permissions
85
+ RUN chown -R root:root $UFPALIGN_DIR && \
86
+ chmod -R 755 $UFPALIGN_DIR
87
+
88
+ # Expose port for API if needed
89
+ EXPOSE 7860
90
+
91
+ # Health check
92
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=60s --retries=3 \
93
+ CMD [ -f "$UFPALIGN_DIR/ufpalign.sh" ] && echo "UFPAlign is ready" || exit 1
94
+
95
+ # Default command
96
+ CMD ["/bin/bash"]
Makefile.ufpalign ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UFPAlign Docker Management Makefile
2
+ # Inspired by Docker containerizing test tooling best practices
3
+
4
+ # Variables
5
+ IMAGE_NAME := ufpalign
6
+ HUB_NAMESPACE := your-namespace
7
+ VERSION := $(shell date +'%Y%m%d')
8
+ CONTAINER_NAME := ufpalign-container
9
+ API_CONTAINER_NAME := ufpalign-api-container
10
+
11
+ # Docker Compose files
12
+ COMPOSE_FILE := docker-compose.ufpalign.yml
13
+
14
+ # Color output
15
+ RED := \033[31m
16
+ GREEN := \033[32m
17
+ YELLOW := \033[33m
18
+ BLUE := \033[34m
19
+ RESET := \033[0m
20
+
21
+ .PHONY: help version-check clean-image image push test-container run-interactive run-api stop clean setup-dirs
22
+
23
+ help: ## Show this help message
24
+ @echo "$(BLUE)UFPAlign Docker Management$(RESET)"
25
+ @echo ""
26
+ @echo "$(GREEN)Available targets:$(RESET)"
27
+ @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " $(YELLOW)%-20s$(RESET) %s\n", $$1, $$2}' $(MAKEFILE_LIST)
28
+
29
+ version-check: ## Check current version and image status
30
+ @echo "$(BLUE)Current version: $(VERSION)$(RESET)"
31
+ @echo "$(BLUE)Checking for existing images:$(RESET)"
32
+ @docker images | grep $(IMAGE_NAME) || echo "$(YELLOW)No existing images found$(RESET)"
33
+
34
+ setup-dirs: ## Create necessary local directories
35
+ @echo "$(GREEN)Creating local directories...$(RESET)"
36
+ @mkdir -p audio_input text_input output textgrid logs
37
+ @echo "$(GREEN)Directories created successfully$(RESET)"
38
+
39
+ clean-image: version-check ## Remove existing Docker images
40
+ @echo "$(RED)Removing existing images...$(RESET)"
41
+ @docker rmi $(IMAGE_NAME):latest 2>/dev/null || true
42
+ @docker rmi $(IMAGE_NAME):$(VERSION) 2>/dev/null || true
43
+ @docker rmi $(HUB_NAMESPACE)/$(IMAGE_NAME):latest 2>/dev/null || true
44
+ @docker rmi $(HUB_NAMESPACE)/$(IMAGE_NAME):$(VERSION) 2>/dev/null || true
45
+
46
+ image: version-check ## Build the Docker image
47
+ @echo "$(GREEN)Building UFPAlign Docker image...$(RESET)"
48
+ @docker build -t $(IMAGE_NAME):$(VERSION) -f Dockerfile.ufpalign .
49
+ @docker tag $(IMAGE_NAME):$(VERSION) $(IMAGE_NAME):latest
50
+ @docker tag $(IMAGE_NAME):$(VERSION) $(HUB_NAMESPACE)/$(IMAGE_NAME):$(VERSION)
51
+ @docker tag $(IMAGE_NAME):$(VERSION) $(HUB_NAMESPACE)/$(IMAGE_NAME):latest
52
+ @echo "$(GREEN)Image built successfully$(RESET)"
53
+ @docker images | grep $(IMAGE_NAME)
54
+
55
+ push: clean-image image ## Build and push image to registry
56
+ @echo "$(BLUE)Pushing images to registry...$(RESET)"
57
+ @docker push $(HUB_NAMESPACE)/$(IMAGE_NAME):$(VERSION)
58
+ @docker push $(HUB_NAMESPACE)/$(IMAGE_NAME):latest
59
+ @echo "$(GREEN)Images pushed successfully$(RESET)"
60
+
61
+ test-container: image ## Run UFPAlign tests in container
62
+ @echo "$(GREEN)Running UFPAlign tests...$(RESET)"
63
+ @docker run --rm --name ufpalign-test \
64
+ -v $(PWD)/temp_ufpalign/demo:/opt/UFPAlign/test_data:ro \
65
+ $(IMAGE_NAME):latest \
66
+ bash -c "cd /opt/UFPAlign && KALDI_ROOT=/opt/kaldi bash ufpalign.sh test_data/ex.wav test_data/ex.txt mono"
67
+
68
+ run-interactive: setup-dirs image ## Run UFPAlign container interactively
69
+ @echo "$(GREEN)Starting UFPAlign container in interactive mode...$(RESET)"
70
+ @docker run -it --rm \
71
+ --name $(CONTAINER_NAME) \
72
+ -v $(PWD)/audio_input:/opt/UFPAlign/audio_input:ro \
73
+ -v $(PWD)/text_input:/opt/UFPAlign/text_input:ro \
74
+ -v $(PWD)/output:/opt/UFPAlign/output:rw \
75
+ -v $(PWD)/textgrid:/opt/UFPAlign/textgrid:rw \
76
+ -v $(PWD)/logs:/root/logs:rw \
77
+ $(IMAGE_NAME):latest bash
78
+
79
+ run-api: setup-dirs image ## Run UFPAlign with API service
80
+ @echo "$(GREEN)Starting UFPAlign API service...$(RESET)"
81
+ @docker run -d \
82
+ --name $(API_CONTAINER_NAME) \
83
+ -p 7860:7860 \
84
+ -v $(PWD)/audio_input:/opt/UFPAlign/audio_input:ro \
85
+ -v $(PWD)/text_input:/opt/UFPAlign/text_input:ro \
86
+ -v $(PWD)/output:/opt/UFPAlign/output:rw \
87
+ -v $(PWD)/textgrid:/opt/UFPAlign/textgrid:rw \
88
+ -v $(PWD)/logs:/root/logs:rw \
89
+ -v $(PWD)/app.py:/opt/UFPAlign/app.py:ro \
90
+ $(IMAGE_NAME):latest \
91
+ uvicorn app:app --host 0.0.0.0 --port 7860
92
+ @echo "$(GREEN)API service started at http://localhost:7860$(RESET)"
93
+
94
+ compose-up: setup-dirs ## Start services using Docker Compose
95
+ @echo "$(GREEN)Starting UFPAlign services with Docker Compose...$(RESET)"
96
+ @docker-compose -f $(COMPOSE_FILE) up -d
97
+ @echo "$(GREEN)Services started$(RESET)"
98
+
99
+ compose-down: ## Stop Docker Compose services
100
+ @echo "$(RED)Stopping Docker Compose services...$(RESET)"
101
+ @docker-compose -f $(COMPOSE_FILE) down
102
+ @echo "$(GREEN)Services stopped$(RESET)"
103
+
104
+ compose-logs: ## Show Docker Compose logs
105
+ @docker-compose -f $(COMPOSE_FILE) logs -f
106
+
107
+ stop: ## Stop running containers
108
+ @echo "$(RED)Stopping UFPAlign containers...$(RESET)"
109
+ @docker stop $(CONTAINER_NAME) 2>/dev/null || true
110
+ @docker stop $(API_CONTAINER_NAME) 2>/dev/null || true
111
+ @docker rm $(CONTAINER_NAME) 2>/dev/null || true
112
+ @docker rm $(API_CONTAINER_NAME) 2>/dev/null || true
113
+ @echo "$(GREEN)Containers stopped$(RESET)"
114
+
115
+ clean: stop clean-image ## Clean up containers and images
116
+ @echo "$(RED)Cleaning up Docker resources...$(RESET)"
117
+ @docker system prune -f
118
+ @echo "$(GREEN)Cleanup completed$(RESET)"
119
+
120
+ demo: image ## Run a demo with provided sample files
121
+ @echo "$(GREEN)Running UFPAlign demo...$(RESET)"
122
+ @cp temp_ufpalign/demo/ex.wav audio_input/ 2>/dev/null || true
123
+ @cp temp_ufpalign/demo/ex.txt text_input/ 2>/dev/null || true
124
+ @docker run --rm \
125
+ --name ufpalign-demo \
126
+ -v $(PWD)/audio_input:/opt/UFPAlign/audio_input:ro \
127
+ -v $(PWD)/text_input:/opt/UFPAlign/text_input:ro \
128
+ -v $(PWD)/output:/opt/UFPAlign/output:rw \
129
+ -v $(PWD)/textgrid:/opt/UFPAlign/textgrid:rw \
130
+ $(IMAGE_NAME):latest \
131
+ bash -c "cd /opt/UFPAlign && KALDI_ROOT=/opt/kaldi bash ufpalign.sh audio_input/ex.wav text_input/ex.txt mono"
132
+ @echo "$(GREEN)Demo completed. Check output/ and textgrid/ directories$(RESET)"
133
+
134
+ shell: image ## Get a shell in the UFPAlign container
135
+ @echo "$(GREEN)Opening shell in UFPAlign container...$(RESET)"
136
+ @docker run -it --rm \
137
+ --name ufpalign-shell \
138
+ -v $(PWD)/audio_input:/opt/UFPAlign/audio_input:ro \
139
+ -v $(PWD)/text_input:/opt/UFPAlign/text_input:ro \
140
+ -v $(PWD)/output:/opt/UFPAlign/output:rw \
141
+ -v $(PWD)/textgrid:/opt/UFPAlign/textgrid:rw \
142
+ $(IMAGE_NAME):latest bash
143
+
144
+ install-models: image ## Download and install UFPAlign models
145
+ @echo "$(GREEN)Installing UFPAlign models...$(RESET)"
146
+ @docker run --rm \
147
+ --name ufpalign-install-models \
148
+ -v $(PWD)/models:/opt/UFPAlign/models:rw \
149
+ $(IMAGE_NAME):latest \
150
+ bash -c "cd /opt/UFPAlign && \
151
+ utils/download_model.sh data /opt/UFPAlign && \
152
+ utils/download_model.sh mono /opt/UFPAlign && \
153
+ utils/download_model.sh tri1 /opt/UFPAlign && \
154
+ utils/download_model.sh tri2b /opt/UFPAlign && \
155
+ utils/download_model.sh tri3b /opt/UFPAlign && \
156
+ utils/download_model.sh tdnn /opt/UFPAlign && \
157
+ utils/download_model.sh ie /opt/UFPAlign"
158
+ @echo "$(GREEN)Models installed successfully$(RESET)"
README.ufpalign.md ADDED
@@ -0,0 +1,290 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # UFPAlign Docker Implementation
2
+
3
+ This repository provides a comprehensive Docker implementation of [UFPAlign](https://github.com/falabrasil/ufpalign) - a free tool for forced phonetic alignment in Brazilian Portuguese developed by the FalaBrasil group at UFPA.
4
+
5
+ ## Overview
6
+
7
+ UFPAlign is a forced phonetic alignment system specifically designed for Brazilian Portuguese that uses the Kaldi toolkit. This Docker implementation makes it easy to run UFPAlign without complex local installations.
8
+
9
+ ### Features
10
+
11
+ - **Complete UFPAlign Environment**: Pre-configured with Kaldi, Python dependencies, and Brazilian Portuguese locale
12
+ - **Multiple Usage Modes**: Interactive shell, API service, and batch processing
13
+ - **Volume Mapping**: Easy access to input/output files on your host system
14
+ - **Model Management**: Automated downloading and installation of acoustic models
15
+ - **Docker Compose Support**: Easy multi-container deployment
16
+
17
+ ## Quick Start
18
+
19
+ ### Prerequisites
20
+
21
+ - Docker (version 20.10+)
22
+ - Docker Compose (version 1.29+)
23
+ - At least 4GB of available disk space
24
+
25
+ ### 1. Clone and Build
26
+
27
+ ```bash
28
+ # Clone this repository or download the Docker files
29
+ git clone <your-repo-url>
30
+ cd <your-repo-directory>
31
+
32
+ # Build the UFPAlign Docker image
33
+ make -f Makefile.ufpalign image
34
+ ```
35
+
36
+ ### 2. Run a Demo
37
+
38
+ ```bash
39
+ # Run the demo with sample files from UFPAlign repository
40
+ make -f Makefile.ufpalign demo
41
+ ```
42
+
43
+ This will:
44
+ - Copy sample audio and text files to the appropriate directories
45
+ - Run UFPAlign alignment using the monophone model
46
+ - Output results to `output/` and `textgrid/` directories
47
+
48
+ ## Usage Methods
49
+
50
+ ### 1. Interactive Shell
51
+
52
+ Get a shell inside the UFPAlign container for manual operations:
53
+
54
+ ```bash
55
+ make -f Makefile.ufpalign run-interactive
56
+ ```
57
+
58
+ Inside the container, you can run:
59
+ ```bash
60
+ # Basic alignment command
61
+ KALDI_ROOT=/opt/kaldi bash ufpalign.sh audio_input/your_audio.wav text_input/your_text.txt mono
62
+
63
+ # Available acoustic models: mono, tri1, tri2b, tri3b, tdnn
64
+ KALDI_ROOT=/opt/kaldi bash ufpalign.sh audio_input/your_audio.wav text_input/your_text.txt tdnn
65
+ ```
66
+
67
+ ### 2. API Service
68
+
69
+ Run UFPAlign as a web API service:
70
+
71
+ ```bash
72
+ make -f Makefile.ufpalign run-api
73
+ ```
74
+
75
+ The API will be available at `http://localhost:7860`
76
+
77
+ ### 3. Docker Compose (Recommended)
78
+
79
+ Use Docker Compose for a complete setup:
80
+
81
+ ```bash
82
+ # Start all services
83
+ make -f Makefile.ufpalign compose-up
84
+
85
+ # View logs
86
+ make -f Makefile.ufpalign compose-logs
87
+
88
+ # Stop services
89
+ make -f Makefile.ufpalign compose-down
90
+ ```
91
+
92
+ ## Directory Structure
93
+
94
+ The Docker setup creates and uses the following local directories:
95
+
96
+ ```
97
+ your-project/
98
+ ├── audio_input/ # Place your .wav files here (read-only in container)
99
+ ├── text_input/ # Place your .txt transcription files here (read-only)
100
+ ├── output/ # UFPAlign processing outputs (read-write)
101
+ ├── textgrid/ # Generated TextGrid files (read-write)
102
+ ├── logs/ # Processing logs (read-write)
103
+ └── models/ # Downloaded acoustic models (optional)
104
+ ```
105
+
106
+ ## Acoustic Models
107
+
108
+ UFPAlign supports several acoustic model architectures:
109
+
110
+ - **mono**: Monophone model (fastest, basic alignment)
111
+ - **tri1**: First triphone model
112
+ - **tri2b**: Second triphone model with feature transforms
113
+ - **tri3b**: Third triphone model with speaker adaptation
114
+ - **tdnn**: Time Delay Neural Network (best quality, requires more resources)
115
+
116
+ ### Installing Models
117
+
118
+ ```bash
119
+ # Download and install all models (requires significant time and bandwidth)
120
+ make -f Makefile.ufpalign install-models
121
+ ```
122
+
123
+ Models are automatically downloaded on first use if not present.
124
+
125
+ ## File Formats
126
+
127
+ ### Input Files
128
+
129
+ 1. **Audio Files** (`audio_input/`):
130
+ - Format: WAV (16-bit, mono recommended)
131
+ - Sample rate: 16kHz recommended (UFPAlign can handle others)
132
+ - Example: `audio_input/my_recording.wav`
133
+
134
+ 2. **Text Files** (`text_input/`):
135
+ - Format: Plain text with orthographic transcription
136
+ - Encoding: UTF-8
137
+ - Content: Brazilian Portuguese text matching the audio
138
+ - Example: `text_input/my_recording.txt`
139
+
140
+ ### Output Files
141
+
142
+ 1. **TextGrid Files** (`textgrid/`):
143
+ - Praat-compatible TextGrid format
144
+ - Multiple tiers: phonemes, syllables, words, phonetic transcription, orthographic transcription
145
+
146
+ 2. **Processing Outputs** (`output/`):
147
+ - CTM (Conversation Time Mark) files
148
+ - Intermediate processing files
149
+ - Alignment statistics
150
+
151
+ ## Makefile Commands
152
+
153
+ The included Makefile provides convenient commands for managing the Docker setup:
154
+
155
+ ```bash
156
+ # Get help with all available commands
157
+ make -f Makefile.ufpalign help
158
+
159
+ # Build the image
160
+ make -f Makefile.ufpalign image
161
+
162
+ # Run demo
163
+ make -f Makefile.ufpalign demo
164
+
165
+ # Interactive shell
166
+ make -f Makefile.ufpalign shell
167
+
168
+ # API service
169
+ make -f Makefile.ufpalign run-api
170
+
171
+ # Docker Compose operations
172
+ make -f Makefile.ufpalign compose-up
173
+ make -f Makefile.ufpalign compose-down
174
+ make -f Makefile.ufpalign compose-logs
175
+
176
+ # Cleanup
177
+ make -f Makefile.ufpalign clean
178
+ ```
179
+
180
+ ## API Usage
181
+
182
+ When running in API mode, you can interact with UFPAlign through HTTP requests:
183
+
184
+ ```bash
185
+ # Example: Upload audio and text for alignment
186
+ curl -X POST "http://localhost:7860/align" \
187
+ -F "audio=@your_audio.wav" \
188
+ -F "text=@your_text.txt" \
189
+ -F "model=mono"
190
+ ```
191
+
192
+ ## Performance Considerations
193
+
194
+ ### Resource Requirements
195
+
196
+ - **RAM**: Minimum 2GB, recommended 4GB+
197
+ - **CPU**: Multi-core recommended for faster processing
198
+ - **Storage**: 2-4GB for base image + models
199
+ - **Network**: Required for initial model downloads
200
+
201
+ ### Model Performance vs Speed
202
+
203
+ - **mono**: Fastest, basic accuracy
204
+ - **tri1, tri2b, tri3b**: Progressive improvement in accuracy
205
+ - **tdnn**: Best accuracy, requires most resources and time
206
+
207
+ ## Troubleshooting
208
+
209
+ ### Common Issues
210
+
211
+ 1. **Permission Errors**:
212
+ ```bash
213
+ # Ensure proper permissions on directories
214
+ chmod -R 755 audio_input text_input output textgrid logs
215
+ ```
216
+
217
+ 2. **Model Download Failures**:
218
+ ```bash
219
+ # Manually install models
220
+ make -f Makefile.ufpalign install-models
221
+ ```
222
+
223
+ 3. **Memory Issues**:
224
+ - Use smaller models (mono instead of tdnn)
225
+ - Increase Docker memory allocation
226
+ - Process smaller audio files
227
+
228
+ 4. **Audio Format Issues**:
229
+ ```bash
230
+ # Convert audio to supported format using sox
231
+ sox input.mp3 -r 16000 -c 1 output.wav
232
+ ```
233
+
234
+ ### Debug Mode
235
+
236
+ Run with debug output:
237
+
238
+ ```bash
239
+ docker run -it --rm \
240
+ -v $(PWD)/audio_input:/opt/UFPAlign/audio_input:ro \
241
+ -v $(PWD)/text_input:/opt/UFPAlign/text_input:ro \
242
+ -v $(PWD)/output:/opt/UFPAlign/output:rw \
243
+ -v $(PWD)/textgrid:/opt/UFPAlign/textgrid:rw \
244
+ ufpalign:latest \
245
+ bash -c "set -x && cd /opt/UFPAlign && KALDI_ROOT=/opt/kaldi bash ufpalign.sh audio_input/your_file.wav text_input/your_file.txt mono"
246
+ ```
247
+
248
+ ## Citation
249
+
250
+ If you use UFPAlign in your research, please cite:
251
+
252
+ ```bibtex
253
+ @article{Batista22a,
254
+ author = {Batista, Cassio and Dias, Ana Larissa and Neto, Nelson},
255
+ title = {Free resources for forced phonetic alignment in Brazilian Portuguese based on Kaldi toolkit},
256
+ journal = {EURASIP Journal on Advances in Signal Processing},
257
+ year = {2022},
258
+ month = {Feb},
259
+ day = {19},
260
+ volume = {2022},
261
+ number = {1},
262
+ pages = {11},
263
+ issn = {1687-6180},
264
+ doi = {10.1186/s13634-022-00844-9},
265
+ url = {https://doi.org/10.1186/s13634-022-00844-9}
266
+ }
267
+ ```
268
+
269
+ ## License
270
+
271
+ This Docker implementation follows the same MIT license as the original UFPAlign project.
272
+
273
+ ## Support
274
+
275
+ - **Original UFPAlign**: [GitHub Repository](https://github.com/falabrasil/ufpalign)
276
+ - **FalaBrasil Group**: [Website](https://ufpafalabrasil.gitlab.io/)
277
+ - **Docker Issues**: Create an issue in this repository
278
+
279
+ ## Contributing
280
+
281
+ 1. Fork this repository
282
+ 2. Create a feature branch
283
+ 3. Make your changes
284
+ 4. Test with the provided demo
285
+ 5. Submit a pull request
286
+
287
+ ---
288
+
289
+ **Grupo FalaBrasil (2024)** - https://ufpafalabrasil.gitlab.io/
290
+ **Universidade Federal do Pará (UFPA)** - https://portal.ufpa.br/
docker-compose.ufpalign.yml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ ufpalign:
5
+ build:
6
+ context: .
7
+ dockerfile: Dockerfile.ufpalign
8
+ image: ufpalign:latest
9
+ container_name: ufpalign-container
10
+ environment:
11
+ - KALDI_ROOT=/opt/kaldi
12
+ - UFPALIGN_DIR=/opt/UFPAlign
13
+ - LC_ALL=pt_BR.UTF-8
14
+ - LANG=pt_BR.UTF-8
15
+ volumes:
16
+ # Map local directories to container
17
+ - ./audio_input:/opt/UFPAlign/audio_input:ro
18
+ - ./text_input:/opt/UFPAlign/text_input:ro
19
+ - ./output:/opt/UFPAlign/output:rw
20
+ - ./textgrid:/opt/UFPAlign/textgrid:rw
21
+ - ./logs:/root/logs:rw
22
+ ports:
23
+ - "7860:7860"
24
+ working_dir: /opt/UFPAlign
25
+ stdin_open: true
26
+ tty: true
27
+ restart: unless-stopped
28
+ command: /bin/bash
29
+
30
+ ufpalign-api:
31
+ build:
32
+ context: .
33
+ dockerfile: Dockerfile.ufpalign
34
+ image: ufpalign:latest
35
+ container_name: ufpalign-api-container
36
+ environment:
37
+ - KALDI_ROOT=/opt/kaldi
38
+ - UFPALIGN_DIR=/opt/UFPAlign
39
+ - LC_ALL=pt_BR.UTF-8
40
+ - LANG=pt_BR.UTF-8
41
+ volumes:
42
+ - ./audio_input:/opt/UFPAlign/audio_input:ro
43
+ - ./text_input:/opt/UFPAlign/text_input:ro
44
+ - ./output:/opt/UFPAlign/output:rw
45
+ - ./textgrid:/opt/UFPAlign/textgrid:rw
46
+ - ./logs:/root/logs:rw
47
+ - ./app.py:/opt/UFPAlign/app.py:ro
48
+ ports:
49
+ - "7861:7860"
50
+ working_dir: /opt/UFPAlign
51
+ restart: unless-stopped
52
+ command: uvicorn app:app --host 0.0.0.0 --port 7860
53
+ depends_on:
54
+ - ufpalign