Skip to content

Feature: Narration Mode (Text-to-Speech for Stories) #21

Description

@SrishtiSonam

Hi @my-projects-it, I explored this application and found it truly inspiring. I’d love to suggest a new feature to enhance the experience, a Narration Mode, as many users often prefer listening to stories rather than reading them.
I've outlined the idea in detail below. Looking forward to your thoughts and discuss it further!


Overview

Add an optional Text-to-Speech (TTS) feature to allow users to listen to submitted stories. This improves accessibility and emotional impact, especially for visually impaired users or those who prefer auditory experiences.


What it Does

  • Adds a “Listen to this story” button under each text submission
  • Converts the story content into speech using a soothing, language-appropriate voice
  • Plays the audio inline within the Streamlit app

Technical Implementation

Packages

  • gTTS – Google Text-to-Speech for multilingual support (supports Hindi, Tamil, Bengali, etc.)
  • tempfile – for managing temporary audio file storage
  • Streamlit's st.audio() – to play audio in-browser

Steps to Implement

  1. Create a button:
    if st.button(" Listen to this story"):

  2. Convert story text to speech using gTTS:
    from gtts import gTTS
    import tempfile
    tts = gTTS(text=story_text, lang="hi") # or "en", "ta", etc.
    temp_audio = tempfile.NamedTemporaryFile(delete=False, suffix=".mp3")
    tts.save(temp_audio.name)

  3. Play audio in Streamlit:
    st.audio(temp_audio.name)

  4. Clean up temp files periodically:
    You can use a cleanup script or schedule to delete old audio files.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is needed

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions