Investigate: better text-to-speech for articles in de Volkskrant and De Gelderlander #55
Labels
No labels
area/architecture
area/build-ci
area/bytecode
area/code-quality
area/docs
area/extension
area/fingerprint
area/security
area/tests
Bug report
Feature request
review
sev/low
sev/medium
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
midas/midas-patches#55
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Affects de Volkskrant (DPG Edition) and De Gelderlander (Kubus). Exploratory: may well end in "not feasible".
Problem
Both apps have a "listen to article" feature (VK: Artikel luisteren, "automatisch gegenereerde digitale stem"; DG: Artikel luisteren, still labelled "in ontwikkeling"). The voice quality is poor. Can we improve it, for example by routing the article text to a better (third-party or on-device) TTS engine?
First pointers (from a quick look, not verified)
de Volkskrant 7.52.0 (
nl.persgroep.edition.article.*, unobfuscated):data/datasource/remote/dto/TextToSpeechDto(articleUrl,articleUrn,durationMs,imageUrl,title,totalDurationMinutes) mapped todomain/model/TextToSpeech. AdurationMssuggests server-rendered audio rather than Android'sTextToSpeechengine.presentation/ArticleAudioViewModel,ArticleAudioViewStateMapper,ArticleAudioDependencies; UI inArticleScreenKt/ui/header/ArticleHeaderRowKt/HeaderTextToSpeechViewData.isTextToSpeechEnabled,isTtsAutoplayNextEnabled(remote_config_defaults.xml). Audio/podcasts go throughnl.dpgmedia.mcdpg.amalia.*.De Gelderlander 9.21.1 (obfuscated):
com.popular.core.model.data.ArticleItem.textToSpeechEnabled;com.kubusapp.article.components.ttsrecommendations.TtsRecommendationsViewModel.Questions to answer
TextToSpeechengine?Voice?TextToSpeechwith a high-quality Dutch voice, fed with the article text (we already know the article model, see #52);Out of scope / constraints
Outcome
Research notes in
docs/apps/volkskrant.mdanddocs/apps/gelderlander.md, and either a follow-upfeat:issue with a concrete approach or a short "not worth it, because ..." and close.Quick research: model options and cost (2026-10-10)
Desk research only, nothing tested yet.
On-device (phone)
Design idea: sherpa-onnx can be installed as the Android system TTS engine. The patch then only has to feed article text to
android.speech.tts.TextToSpeech; engine and voice are the user's choice in Android settings. No model in the bundle (the extension is dex only anyway).Self-hosted on the RTX 5090 laptop (24 GB VRAM)
Both should generate faster than real time on that GPU. Architecture: an optional "custom TTS endpoint" in Midas Settings; the extension POSTs the article text and plays back the audio. Requires the laptop to be on and reachable (e.g. Tailscale); fall back to the system TTS engine otherwise. No secrets in the bundle: the URL is user-configured.
Paid cloud (comparison)
Azure / Google Cloud neural voices: roughly $15–16 per 1M characters (from memory, verify), so about €0.10 per article. ElevenLabs is several times that. Needs a user-supplied key and sends article text to a third party.
Suggested next steps
TextToSpeechDto.durationMspoints to server-rendered audio, so the patch would replace the audio source rather than pick a voice.Sources: VoxSherpa TTS, Piper vs Kokoro (PromptQuorum), Piper vs Kokoro (CodeSOTA), Kokoro on Android, Chatterbox Multilingual, NVIDIA Chatterbox model card, Chatterbox README, XTTS docs.
Findings (VK 7.52.0, DG 9.21.1)
Short answer: both apps play pre-rendered server audio. Neither uses Android's TextToSpeech engine, so "pick a better engine/voice" (question 2) has nothing to hook.
Shared pipeline (both apps, unobfuscated
nl.dpgmedia.mcdpg.amalia.*SDK)AmaliaEnvironmentProvider→https://tts.api.dpgmedia.cloud(acceptance:tts-test.api.dpgmedia.cloud).ArticleAudioUrnApi.fetchArticleAudioItem(urn)→GET /api/v2/clips/<urlencoded article URN>→ArticleAudioUrnClipDto{articleUrn, audioUrl, durationMs, id, title, descriptionHtml, ttsDisclaimer}. The vendor behind DPG's TTS service is not visible in the APK, and the audio format (mp3 or HLS) isn't visible either.AmaliaArticleAudioMapper→AmaliaAudioPlayable(streams=[AmaliaAudioStream(audioUrl, Audio)])→AmaliaAudioPlayableMediaItemMapper.toMediaItem(Media3MediaItem,Uri.parse(streamUrl)) →MediaController→AmaliaAudioPlayerService(aMediaSessionServicethat owns the ExoPlayer and the notification).DefaultMediaSourceFactory(DefaultDataSource.Factory), sofile://andcontent://URIs should play too (inferred).AmaliaPlaybackSpeedProvider: 0.5–2.0, stored underamalia_audio_playback_speed). There is no voice option.android.speech.ttsonly appears in the PSPDFKit PDF viewer (VK); DG has zero hits.de Volkskrant
textToSpeechis metadata only; it has no URL.ArticleAudioViewModel.launchTtsPlayer→AudioSdkLauncher.Request.Single(ArticleMetadata(urn, …))→ paywall check (AuthCheck.AudioPaywall) →AudioPlayableResolver→ URN fetch above.isTtsAutoplayNextEnabled, overview pages only) queues URNs and resolves each one lazily through the same fetch.AmaliaCarPlaybackPreparer) also calls the same fetch.De Gelderlander
FEATURE_TTS_PLAYER(call-site default"disabled", inydd.g=TtsPlayer.kt). The "in ontwikkeling" note is gated byFEATURE_TTS_FEEDBACK_ARTICLE_DETAILS(BuildConfig"disabled").ArticleItem.textToSpeechEnabledis a backend flag for "this article has audio".TtsRecommendationsViewModelonly builds the "next to listen" list from the cross-promotion feed.Feasibility
The least invasive hook for a better voice is
ArticleAudioUrnApi.fetchArticleAudioItem(String, Continuation). It is the same class in both apps, unobfuscated, and already runs onDispatchers.IO.How it would work: an extension synthesizes the article text to a file with a better voice, then returns an
ArticleAudioUrnClipDtowhoseaudioUrlisfile://…. Everything downstream stays intact: media session, notification, queue/autoplay-next, speed and the paywall check. The same extension code and nearly the same hook would serve both apps.Open problems:
ArticleViewModel.getCurrentArticle()). Autoplay-next queue items would need a URN → article fetch (the URN ↔ shortId mapping is unverified). Simplest fallback: only replace the audio when we have the body cached, otherwise keep DPG's audio.TextToSpeech.synthesizeToFilewith the best installed Dutch voice (Voice.QUALITY_VERY_HIGH, no network). It is unclear whether that actually beats DPG's voice; listen first.Recommendation: before any implementation, do a cheap spike that only checks voice quality. Take one article's text, run
synthesizeToFilewith the phone's best Dutch voice and compare it by ear with DPG's clip. If it isn't clearly better, close this issue as "not worth it".Research by two Claude Sonnet subagents; key claims (host, endpoint, no device TTS, DG flag) spot-checked in the decompiled code.
Findings & Outcome
Investigated the TTS implementation across both de Volkskrant (7.52.0) and De Gelderlander (9.21.1).
1. Audio Source
Neither app uses Android's on-device
android.speech.tts.TextToSpeechengine. The audio is 100% pre-rendered server audio generated on DPG's cloud infrastructure:GET https://tts.api.dpgmedia.cloud/api/v2/clips/{articleUrn}ArticleAudioViewModel.launchTtsPlayer->AudioSdkProvidedInterface.AudioLauncher->ArticleAudioUrnApi.fetchArticleAudioItemArticleAudioUrnDtocontainingArticleAudioUrnClipDtowithaudioUrl(direct streaming URL) anddurationMs.AmaliaArticleAudioMapperintoAmaliaAudioStream(audioUrl, Audio)and played through DPG's shared audio engine (nl.dpgmedia.mcdpg.amalia.*via ExoPlayer / Media3).amaliaaudio player stack.2. Feasibility of Swapping Voices
TextToSpeech.synthesizeToFile) to local files and redirecting Amalia's audio player is slow on mobile hardware and introduces large architectural complexity.copyArticleMarkdownPatch), users can easily copy full article text to clipboard and open it in dedicated screen reader apps (Pocket, Voice Dream Reader, @Voice Aloud Reader).Conclusion
Replacing the server-rendered TTS audio stream inside the app's player is not feasible as a clean bytecode patch. Documented the full architecture in
docs/apps/volkskrant.mdanddocs/apps/gelderlander.md(commit 780f804) and closing as not feasible / won't fix.