# googlecloudplatform/text-to-speech-epg-demo architecture

> Architecture diagram of the GitHub repository googlecloudplatform/text-to-speech-epg-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/googlecloudplatform/text-to-speech-epg-demo
- Repository: https://github.com/googlecloudplatform/text-to-speech-epg-demo

## Overview

This demo lets an EPG user request spoken program text and play the resulting audio. The UI sends text and voice options to a Go HTTP service, which checks for cached audio, synthesizes a miss, stores the MP3, signs an access URL, and returns it for playback through the CDN. The README documents this end-to-end flow and startup secret loading. Several helper implementations are sampled, but the UI’s JavaScript and secret-loading implementation are not; those links are shown only where documented or directly visible in the excerpts.

Main entry points: [`get-speech-service/src/main.go`](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/main.go) (Speech HTTP API), [`epg-ui/src/index.html`](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/epg-ui/src/index.html) (Mock EPG UI), [`get-speech-service/src/text_to_speech_helpers.go`](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/text_to_speech_helpers.go) (Speech synthesis), [`get-speech-service/src/secret_manager_helpers.go`](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/secret_manager_helpers.go) (Signing-key loader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_demo["EPG Demo"]
  node_epg_ui["Mock EPG UI<br/>[index.html]"]
  node_epg_items["EPG items<br/>[epg-items.json]"]
end

subgraph group_request["Speech Requests"]
  node_http_api["Speech HTTP API<br/>[main.go]"]
  node_cache_lookup["Cache lookup<br/>[main.go]"]
  node_request_hash["Request hashing<br/>[crypto_helpers.go]"]
end

subgraph group_audio["Audio Pipeline"]
  node_audio_store[("Audio storage<br/>[gcs_helpers.go]")]
  node_speech_synthesis["Speech synthesis"]
end

subgraph group_access["Secure Delivery"]
  node_url_signing["URL signing<br/>[gcs_helpers.go]"]
  node_secret_loader["Signing-key loader"]
end

node_epg_user(("EPG user"))
node_speech_client(("Speech client"))
node_tts_api["Cloud Text-to-Speech"]
node_secret_manager[("Secret Manager")]
node_cdn["Cloud CDN"]
node_listener(("Audio listener"))

node_epg_user -->|"selects text"| node_epg_ui
node_epg_items -.->|"provides items"| node_epg_ui
node_epg_ui -->|"requests speech"| node_http_api
node_speech_client -->|"posts text"| node_http_api
node_http_api -->|"fetches audio"| node_cache_lookup
node_cache_lookup -->|"hashes request"| node_request_hash
node_cache_lookup -->|"checks object"| node_audio_store
node_cache_lookup -->|"generates on miss"| node_speech_synthesis
node_speech_synthesis -->|"synthesizes text"| node_tts_api
node_speech_synthesis -->|"uploads MP3"| node_audio_store
node_http_api -->|"signs audio URL"| node_url_signing
node_url_signing -->|"decodes key"| node_secret_loader
node_http_api -->|"loads key at startup"| node_secret_loader
node_secret_loader -->|"reads signing key"| node_secret_manager
node_http_api -->|"returns signed URL"| node_speech_client
node_epg_ui -->|"loads audio"| node_cdn
node_speech_client -->|"loads audio"| node_cdn
node_cdn -->|"fetches cache miss"| node_audio_store
node_epg_ui -->|"plays audio"| node_listener

click node_epg_ui "https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/epg-ui/src/index.html"
click node_epg_items "https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/epg-ui/src/epg-items.json"
click node_http_api "https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/main.go"
click node_cache_lookup "https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/main.go"
click node_request_hash "https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/crypto_helpers.go"
click node_audio_store "https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/gcs_helpers.go"
click node_speech_synthesis "https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/text_to_speech_helpers.go"
click node_url_signing "https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/gcs_helpers.go"
click node_secret_loader "https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/secret_manager_helpers.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_epg_ui,node_epg_items,node_epg_user,node_speech_client toneBlue
class node_http_api,node_cache_lookup,node_request_hash,node_secret_manager toneAmber
class node_audio_store,node_speech_synthesis toneMint
class node_url_signing,node_secret_loader toneRose
class node_tts_api,node_cdn,node_listener toneIndigo
```

## Components

### EPG Demo

- [Mock EPG UI](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/epg-ui/src/index.html): `epg-ui/src/index.html`
- [EPG items](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/epg-ui/src/epg-items.json): `epg-ui/src/epg-items.json`

### Speech Requests

- [Speech HTTP API](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/main.go): `get-speech-service/src/main.go`
- [Cache lookup](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/main.go): `get-speech-service/src/main.go`
- [Request hashing](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/crypto_helpers.go): `get-speech-service/src/crypto_helpers.go`

### Audio Pipeline

- [Audio storage](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/gcs_helpers.go): `get-speech-service/src/gcs_helpers.go`
- [Speech synthesis](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/text_to_speech_helpers.go): `get-speech-service/src/text_to_speech_helpers.go`

### Secure Delivery

- [URL signing](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/gcs_helpers.go): `get-speech-service/src/gcs_helpers.go`
- [Signing-key loader](https://github.com/googlecloudplatform/text-to-speech-epg-demo/blob/master/get-speech-service/src/secret_manager_helpers.go): `get-speech-service/src/secret_manager_helpers.go`

### Other components

- **EPG user**
- **Speech client**
- **Cloud Text-to-Speech**
- **Secret Manager**
- **Cloud CDN**
- **Audio listener**

## Connections

- EPG user → Mock EPG UI: selects text (evidence: `README.md`)
- EPG items → Mock EPG UI: provides items
- Mock EPG UI → Speech HTTP API: requests speech (evidence: `README.md`)
- Speech client → Speech HTTP API: posts text (evidence: `README.md`)
- Speech HTTP API → Cache lookup: fetches audio (evidence: `get-speech-service/src/main.go`)
- Cache lookup → Request hashing: hashes request (evidence: `get-speech-service/src/main.go`)
- Cache lookup → Audio storage: checks object (evidence: `get-speech-service/src/main.go`)
- Cache lookup → Speech synthesis: generates on miss (evidence: `README.md`)
- Speech synthesis → Cloud Text-to-Speech: synthesizes text (evidence: `get-speech-service/src/text_to_speech_helpers.go`)
- Speech synthesis → Audio storage: uploads MP3 (evidence: `get-speech-service/src/text_to_speech_helpers.go`)
- Speech HTTP API → URL signing: signs audio URL (evidence: `get-speech-service/src/main.go`)
- URL signing → Signing-key loader: decodes key (evidence: `get-speech-service/src/gcs_helpers.go`)
- Speech HTTP API → Signing-key loader: loads key at startup (evidence: `get-speech-service/src/main.go`)
- Signing-key loader → Secret Manager: reads signing key (evidence: `README.md`)
- Speech HTTP API → Speech client: returns signed URL (evidence: `README.md`)
- Mock EPG UI → Cloud CDN: loads audio (evidence: `README.md`)
- Speech client → Cloud CDN: loads audio (evidence: `README.md`)
- Cloud CDN → Audio storage: fetches cache miss (evidence: `README.md`)
- Mock EPG UI → Audio listener: plays audio (evidence: `README.md`)
