You can add Gemini text-to-speech to an Angular web app with Firebase AI Logic’s JavaScript SDK: send text to a TTS model, receive audio, then decode and play the returned PCM in the browser. For earlier playback, use the streaming method and process audio chunks as they arrive. This is streamed narration, not a live conversational voice session.
What “real-time” means for Gemini TTS
Firebase describes TTS as “a unidirectional, request-response interaction (text in, audio out).” It is suited to reading supplied text, such as an article or narration. Gemini Live API is the bidirectional option for an ongoing voice conversation, where the model can respond dynamically rather than simply recite a supplied passage. The two APIs serve different interaction patterns; see Firebase’s audio-generation guide.
As an Amazon Associate I earn from qualifying purchases.
| Decision | Gemini TTS | Gemini Live API |
|---|---|---|
| Interaction | One-way: text in, generated speech out | Two-way, live voice interaction |
| What is spoken | Supplied text, with optional style or sound direction | Context-sensitive responses during a conversation |
| Typical use | Article reading, narration, audiobooks | Dynamic conversational voice experiences |
| Integration shape | generateContent or streamed generateContentStream; handle generated PCM |
Stateful live session with streamed audio input and output |
What you need in an Angular project
- A Firebase project with a registered web app and Firebase’s JavaScript SDK installed.
- Firebase AI Logic configured for the Gemini API provider you intend to use.
- An Angular TypeScript location for Firebase initialization and model calls. Firebase documents the web JavaScript SDK, not a dedicated Angular wrapper or a specific tested Angular version; integrating it in an Angular service is an application-level choice.
- A browser playback implementation for the raw PCM data returned by the model. Firebase’s example demonstrates decoding the data but leaves the playback function to the developer.
Follow Firebase’s current getting-started workflow to create or select the Firebase project, register the web app, configure the provider, and install the SDK. Keep project initialization consistent with the app’s existing Angular setup. Firebase AI Logic routes client requests through its proxy service, so do not put a Gemini Developer API key in Angular source.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Initialize Firebase AI Logic and configure the TTS model
The Firebase web example imports the AI Logic helpers from firebase/ai and selects the Gemini Developer API backend. This is the documented JavaScript shape; adapt the Firebase app reference to your own initialization rather than treating the snippet as a complete Angular app.
#1 Best Overall
- [Immersive Sound Experience & Dual Connectivity] Experience unparalleled sound quality with this wireless Bluetooth speaker's 2 drivers and advanced technology that delivers powerful, well-balanced sound with minimal distortion. Connect two speakers together to create an immersive stereo sound experience and fill any room with powerful sound. Perfect for gaming, music, and movie playback
- [Tough & Weather-Resistant] Engineered to handle rough use and adverse weather conditions, this speaker features a durable design and an IPX5 rating for protection against water splashes and spills. It's an ideal choice for outdoor events, and is perfect for use at parties, at the pool, on the beach, while camping or hiking, and more
- [Long-lasting Playtime & Extended Bluetooth Connectivity] Experience extended playtime with up to 24 hours(50% Vol and light off) per charge and extended wireless range with Bluetooth 5.3, reaching up to 100 feet from your device. The multicolor lights on the speaker can also be turned off with a simple button press to save the battery and adapt to your needs. Keep in mind that the actual playtime can vary depending on volume level, audio content, and usage
- [Vibrant Light Effects] Bring a new level of excitement to your party with the dynamic multi-color light show that syncs to the beat of the music, you can easily customize the light effects to suit your preference by simply pressing the Light button. Make any gathering more memorable with these visually stunning light effects that will elevate the atmosphere
- [Everything You Need] The package includes 1 waterproof Bluetooth speaker (Item Dimensions D x W x H: 7.87"D x 2.76"W x 2.81"H, Weight: 1.28lb), 1 Type-C charging cable, and a quick start guide, all backed by lifetime technical support. The built-in microphone allows for hands-free phone calls and you can also play music from other devices using the AUX jack (not included). It's a perfect gift for men and women. It is also suitable as white elephant gifts for adult, stocking stuffers for men and women, Christmas gifts,birthday gifts, mothers day gifts,fathers day gifts,Valentine's Day,mens gifts,and various anniversary gifts for him.
import { getAI, getGenerativeModel, GoogleAIBackend, ResponseModality } from "firebase/ai";
const ai = getAI(firebaseApp, { backend: new GoogleAIBackend() });
const model = getGenerativeModel(ai, {
model: "gemini-3.1-flash-tts-preview",
generationConfig: {
responseModalities: [ResponseModality.AUDIO],
speechConfig: {
voiceConfig: {
prebuiltVoiceConfig: { voiceName: "Kore" }
}
}
}
});
The example uses the Gemini Developer API backend. If your Firebase project uses the Agent Platform Gemini API, choose the corresponding provider setup in Firebase AI Logic instead of copying that backend choice unchanged. The documented Gemini 3.x TTS model ID is gemini-3.1-flash-tts-preview. Firebase’s model reference lists it as Preview with a release date of 2026-06-17; confirm that the model is available for your selected provider and project before relying on it. Preview features can change incompatibly and do not carry an SLA or deprecation policy. Check the supported-model reference for current status.
Send text and choose a voice
In the single-speaker configuration, specify a prebuilt voice name. The language code is optional; if omitted, the guide says the language can be auto-detected. For predictable language selection, configure a code such as en-US in the speech configuration, following Firebase’s TTS configuration guide.
Rank #2
- Outdoor-Proof Speaker: Portable design with IPX7 waterproof protection to safeguard against splashes, waves, and water vapor. Get incredible sounds at home, on camping trips, or for outdoor adventures.
- 24H Non-Stop Music: With Anker's world-renowned power management technology and a 5,200mAh Li-ion battery, the soundcore 2 speaker delivers a full day of great sound.
- Powerful Sound: The speaker features 12W power with enhanced bass from dual neodymium drivers. An advanced digital signal processor ensures pounding bass and zero distortion at any volume.
- Intense Bass: Our exclusive BassUp technology and a patented spiral bass port boost low-end frequencies to make the beats hit even harder. The soundcore 2 speaker delivers vibrant audio for home theater nights, beach parties, and sitting around a campfire.
- Grab, Go, Listen: A classic design refined with simple controls and effortless portability. Easy to use and take anywhere, and supports wireless stereo pairing.
For a complete response, send the text with generateContent:
Free tools Windows power users keep installed
One-click scans. No signup required.
const result = await model.generateContent("Read this text aloud: Welcome to the app.");
const response = result.response;
The response contains inline audio data encoded as base64. Extract the audio part from the response, decode it, and pass the resulting bytes to your playback code. The exact response-part extraction and browser playback are application responsibilities; the SDK example does not provide a ready-made Angular audio component.
Rank #3
- Wireless Bluetooth streaming
- 12 hours of playtime
- IPX7 waterproof
- Pair multiple speakers with party boost
- Premium JBL sound quality
Stream audio chunks in the browser
For Gemini 3.x TTS, Firebase documents generateContentStream so your app can handle response chunks as they arrive rather than waiting for the entire response. This can reduce the wait before playback begins, but Firebase’s cited guide does not establish a numeric latency guarantee.
const stream = await model.generateContentStream("Read this text aloud: Welcome to the app.");
for await (const chunk of stream.stream) {
// Find the audio part in this chunk, decode its base64 data,
// then enqueue the PCM bytes in your browser playback implementation.
}
Each received audio chunk must be extracted and handled in order. Firebase’s browser example shows base64 decoding to an ArrayBuffer; it does not implement chunk buffering or playback. In an Angular UI, keep the stream and playback lifecycle under application control:
Rank #4
- Compact and Powerful Design: Engineered with premium craftsmanship, this portable speaker features a space-saving form measuring a mere 2.99 inches (7.6 cm) in width and length, and 4.25 inches (10.8 cm) in height. Ultra-lightweight at just 0.582 lbs (264g), it slips effortlessly into any bag. Driven by a robust 20W peak power, it delivers immersive audio with punchy bass and crisp highs, while its 15W continuous output ensures crystal-clear sound for indoor relaxation or outdoor adventures
- 【IPX5 Waterproof – Beach, Pool & Outdoor Adventures】Built for everyday outdoor fun, this portable Bluetooth speaker features IPX5 waterproof protection to handle splashes, light rain, and wet environments. Take it to the beach, pool, campsite, backyard, patio, or shower for music wherever you go. A reliable companion for travel, camping, outdoor gatherings, and weekend adventures
- 【Portable Companion – Travel, Camping & Everyday Use】At just 0.58 lbs, this compact wireless speaker easily fits into a backpack, tote, suitcase, or travel bag. The built-in lanyard makes it easy to carry or hang from a backpack, bike, hook, or shower caddy. Great for road trips, beach days, camping trips, dorm rooms, home offices, and relaxing at home
- 【Dynamic Lights – Create the Right Mood Anywhere】Dynamic LED lights add colorful visual effects to your favorite music, bringing extra energy to parties, gatherings, and everyday listening. Use it in the bedroom, dorm, backyard, patio, campsite, or party space. A fun choice for Halloween music, movie nights, sleepovers, game nights, and outdoor hangouts
- 【15W HD Sound & 15H Playtime – Music for Every Moment】Powerful 15W HD sound delivers clear, enjoyable audio for music, podcasts, games, and more. With up to 15 hours of playtime, enjoy your playlist during travel, beach trips, camping, pool days, backyard gatherings, or a relaxing night at home. Keep the music going without frequent recharging
- Show loading and playback state so users can tell whether speech is being generated or played.
- Preserve chunk order and buffer audio so the output does not race ahead of playback.
- Provide a stop or cancel action and discard pending chunks when a user starts another request or leaves the view.
- Handle request, decoding, and playback errors, and release audio resources when playback ends or the component is destroyed.
Those are implementation considerations for a responsive browser experience, not behavior supplied by the Firebase sample. Test playback in the browsers and devices your app supports.
Protect a client-side feature before launch
Client-side access means users can invoke the feature from their browsers, so configure safeguards before making it public. Firebase recommends App Check to help protect model-access APIs from unauthorized clients. Firebase AI Logic also provides configurable per-user rate limits. Review those limits and your provider configuration for the expected use of your app. These controls help manage access and abuse; they do not guarantee that every unauthorized request or unwanted cost is prevented.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




