Possibility to integrate a custom STT into SIPREC
Hello,
Thank you for your work on this SIPREC project! I would like to ask whether it’s possible to integrate a custom STT engine into your solution.
If yes, could you please clarify:
- Which functions or interfaces need to be implemented in order to plug in a custom STT module?
- Is there an existing extension point or abstraction layer for media processing where STT could be added?
- Do you have any examples or guidelines for such integration?
This would help me better understand how to extend your solution with my own STT component.
Thank you in advance!
This is something I would also like to be able to do...
Yes, you can plug in your own STT engine without patching the core. Here’s how:
———
1. Implement the STT provider interface
Every engine implements pkg/stt/provider.go. The minimal contract is:
type Provider interface { Initialize() error Name() string StreamToText(ctx context.Context, audio io.Reader, callUUID string) error }
- If you want real-time callbacks for interim/final text, implement StreamingProvider (adds SetCallback).
- If you need graceful teardown, use EnhancedStreamingProvider.
Inside StreamToText, you’re free to call your engine over HTTP, WebSocket, CLI, etc. When you receive a transcript, push it back through the callback (for streaming providers) so it flows through the existing PII filter, analytics, WebSocket hub, AMQP listeners, etc.
2. Plug it into the registry
We expose a simple registry in pkg/stt/registry.go. From your module’s init():
func init() { stt.RegisterProviderFactory("myengine", func(logger *logrus.Logger, svc *stt.TranscriptionService) (stt.Provider, error) { return myengine.NewProvider(logger) // svc lets you emit transcripts in streaming mode }) }
During startup, the server now recognizes myengine in the config and instantiates it automatically—no core modifications.
3. Configure it at runtime
Add your provider name to the YAML:
stt: supported_vendors: - myengine - google default_vendor: myengine myengine: endpoint: ws://localhost:5555/transcribe api_key: ...
You can also add a config struct in pkg/config/config.go if you need typed fields (see GoogleSTTConfig/DeepgramSTTConfig for references).
4. Media pipeline hook?
The media path (RTP capture, PCM decoding) is already abstracted in pkg/media/rtp.go; it writes PCM frames into the shared TranscriptionService. Your provider receives the decoded audio stream via the StreamToText call—it doesn’t have to touch the RTP layer. If you need pre-processing, you can wrap the audio reader there or hook into the new analytics pipeline in pkg/realtime/analytics.
5. Examples in the repo
- pkg/stt/google.go — simple HTTP provider.
- pkg/stt/deepgram_enhanced.go / pkg/stt/azure_speech.go — WebSocket streaming providers (great templates for Whisper/DeepSpeech/wav2vec).
- pkg/stt/registry.go — the factory hookup.
- pkg/stt/analytics_listener.go — shows how transcripts are emitted into the rest of the system.
———
In short:
- Implement the provider interface (or streaming variant).
- Register it via stt.RegisterProviderFactory.
- Reference it in supported_vendors in your config.
Once that’s in place, your engine’s transcripts flow through PII redaction, analytics, WebSocket dashboards, and AMQP dispatch automatically.
Let us know if you’d like a starter skeleton or help with the config wiring!
@a72, hopefully this was helpful, I am curious are you building your own custom STT? or you wanna to integrate one of the open source ones?
We have our own STT, thank you — I understood how to plug in a custom implementation. However, I’m unable to use your SIPREC component because the XML does not comply with the RFC. I will open a separate issue regarding this problem.
I fixed the xml, please take a look at it