Case study · iFLYTEK Future · 2024-08 — 2024-11
Voice Cloning Backend
Production APIs and real-time streaming for an AI voice feature.
Role · Backend engineer for the Voice Double feature
- Python
- FastAPI
- WebSocket
- CozyVoice
- Alibaba Cloud OSS
- ELK
- Nginx
01
Overview
- Context
- A new headset feature needed to turn a user voiceprint into real-time synthesized speech.
- My contribution
- Designed and implemented the backend integration and its operational boundaries.
- Technology
- Python, FastAPI, WebSocket, CozyVoice, Alibaba Cloud OSS, ELK, and Nginx.
- Result
- Delivered the Voice Double backend for the 2024 Singles' Day product launch.
02
The Problem
The feature had to coordinate lifecycle requests, live synthesis, model serving, durable voiceprint storage, observability, deployment, and operations within one delivery window.
03
My Role
Backend engineer for the Voice Double feature
- Designed and implemented HTTP lifecycle APIs and WebSocket streaming interfaces with FastAPI.
- Integrated CozyVoice model serving and Alibaba Cloud OSS voiceprint storage.
- Added the Nginx service boundary and ELK logging needed to operate and debug the backend in production.
04
Architecture
A focused map of the components and responsibility boundaries that matter to this project.
Architecture
Voice synthesis service boundaries
- 01Product client
Lifecycle requests and streaming session
- 02Nginx boundary
Reverse proxy and service entry
- 03Backend API
FastAPI lifecycle operations
- 04Streaming
WebSocket synthesis session
- 05Model service
CozyVoice synthesis boundary
- 06Object storage
Durable voiceprint objects
- 07Observability
Centralized ELK logs
Product clientNginx boundaryservice trafficNginx boundaryBackend APIHTTPNginx boundaryStreamingWebSocketBackend APIObject storagevoiceprintsStreamingModel servicesynthesisBackend APIObservabilitylogsStreamingObservabilitystream events
The product client enters through a simplified Nginx boundary. FastAPI separates lifecycle APIs from the WebSocket streaming session, coordinates CozyVoice model serving and voiceprint storage, and emits operational events to centralized logging. - 01Product client
05
How It Works
The primary sequence that moves work or data through the system.
Flow
Lifecycle and streaming request flow
- 01Request
HTTP operation or WebSocket session
- 02Validation
Check request and session inputs
- 03Route
Separate lifecycle from streaming work
- 04Lifecycle
Coordinate voiceprint storage
- 05Streaming
Coordinate live model synthesis
- 06Response
Return operation or streamed output
- 07Logging
Record service and stream context
RequestValidationreceiveValidationRouteacceptRouteLifecycleHTTPRouteStreamingWebSocketLifecycleResponsecompleteStreamingResponsestreamValidationLoggingrequest contextLifecycleLoggingoperation eventStreamingLoggingstream event
A request enters the FastAPI boundary and is validated before routing. HTTP lifecycle work coordinates voiceprint storage and returns a bounded response; WebSocket work opens a streaming session that coordinates synthesis with the model service. Both paths emit operational context to centralized logging. - 01Request
06
Key Technical Decisions
- Problem
- Lifecycle operations and real-time synthesis had different interaction patterns.
- Choice
- Use HTTP for lifecycle operations and WebSocket for streaming synthesis.
- Why
- Each transport matched the duration and response behavior of the work it carried, keeping the public API easier to reason about.
- Trade-off
- The backend had to operate and observe two interface styles instead of a single transport.
- Problem
- Model inference, object storage, proxying, and logs could become tightly coupled inside one feature implementation.
- Choice
- Treat model serving, voiceprint storage, reverse proxying, and centralized logging as explicit integration boundaries.
- Why
- Clear boundaries made the production responsibilities and failure locations easier to understand and debug.
- Trade-off
- More boundaries introduced additional configuration and cross-service failure modes to manage.
07
Challenges
- Coordinating stateful voiceprint lifecycle operations with a live synthesis stream.
- Making model integration observable enough for production debugging without exposing user data.
08
Outcome
- Delivered the backend for the Voice Double feature for the 2024 Singles' Day product launch.
- Established explicit interfaces for model serving, storage, streaming, proxying, and centralized logs.
09
What I Learned
- Learned
- Production AI features are integration systems, not just model calls; interface and operational boundaries matter as much as inference.
- Reflection
- Separating lifecycle control, real-time streaming, model serving, storage, and observability makes an AI feature easier to operate and explain.
This was an employer-owned production system. Architecture and implementation details shown here are simplified to protect confidential information.