blog.gopenai.com Open in urlscan Pro
162.159.153.4  Public Scan

Submitted URL: http://blog.gopenai.com/turn-your-google-doc-into-an-audio-book-with-chatgpt-and-google-script-16d2a55b1bde
Effective URL: https://blog.gopenai.com/turn-your-google-doc-into-an-audio-book-with-chatgpt-and-google-script-16d2a55b1bde?gi=b2229310c9b4
Submission: On January 30 via api from US — Scanned from US

Form analysis 0 forms found in the DOM

Text Content

Open in app

Sign up

Sign in

Write


Sign up

Sign in




TURN YOUR GOOGLE DOC INTO AN AUDIO BOOK WITH CHATGPT AND GOOGLE SCRIPT

Dilip Kashyap

·

Follow

Published in

GoPenAI

·
4 min read
·
Apr 22, 2023

2



Listen

Share


Image Source: JavaScript Mastery

Gone are the days of tedious and time-consuming reading of lengthy Google
documents! With ChatGPT and Google Apps Script, you can now listen to your
favorite Google documents as an audiobook. This cutting-edge technology is not
only revolutionary but also life-changing for people with visual impairments or
those who prefer auditory learning styles. Whether you’re a busy professional
looking to multitask, a language learner seeking to improve your listening
skills, or a proofreader aiming to detect errors with ease, this innovative tool
will be your ultimate productivity hack.

In this article, we will walk you through the step-by-step process of how to
make your Google Document come to life and speak to you using ChatGPT and Google
Apps Script. Get ready to sit back, relax, and let the magic of speech synthesis
and artificial intelligence do the work for you!


STEP 1: ENABLE GOOGLE APPS SCRIPT

Enable Google Apps Script in your Google account To begin, you need to enable
Google Apps Script in your Google account. This can be done by opening any
Google Document and clicking on the “Extension” menu. From the drop-down menu,
select “Apps Script” to open the Google Apps Script editor.


STEP 2: CREATE A NEW GOOGLE APPS SCRIPT PROJECT

Create a new Google Apps Script project Once you are in the Google Apps Script
editor, create a new project by clicking on the “New project” button. This will
open a new script file where you can start writing your script.


STEP 3: WRITE THE SCRIPT

Write the script to make your Google Document talk to you To make your Google
Document talk to you, you need to write a script that uses ChatGPT to convert
text to speech. The script should be able to read the text in the Google
Document and convert it to speech.

Here’s an example script that you can use:

function readDocument() {
  var doc = DocumentApp.getActiveDocument();
  var body = doc.getBody();
  var text = body.getText();
  var url = "https://api.openai.com/v1/speeches/gpt";
  var response = UrlFetchApp.fetch(url, {
    "method": "post",
    "headers": {
      "Content-Type": "application/json",
      "Authorization": "Bearer YOUR_API_KEY_HERE"
    },
    "payload": JSON.stringify({
      "model": "text-to-speech",
      "text": text,
      "voice": "en-GB-Wavenet-C",
      "speed": 0.7,
      "pitch": 0,
      "volume": 1,
      "personality": "none"
    })
  });
  var data = JSON.parse(response.getContentText());
  var audioUrl = data["data"][0]["url"];
  var audio = UrlFetchApp.fetch(audioUrl).getBlob();
  var audioFile = DriveApp.createFile(audio);
  var playerUrl = "https://docs.google.com/a/google.com/file/d/" + audioFile.getId() + "/preview";
  var iframe = "<iframe src='" + playerUrl + "' width='640' height='480'></iframe>";
  DocumentApp.getUi().showModalDialog(HtmlService.createHtmlOutput(iframe), "Document Audio");
}

This script uses the ChatGPT API to convert the text in your Google Document to
speech. You will need to replace “YOUR_API_KEY_HERE” with your actual ChatGPT
API key.


STEP 4: RUN THE SCRIPT

Run the script After writing the script, save it and then run it by clicking on
the “Run” button. When you run the script, a modal dialog box will appear
displaying the audio player for your Google Document.


STEP 5: LISTEN TO YOUR GOOGLE DOCUMENT

Listen to your Google Document Click on the “Play” button in the audio player to
listen to your Google Document. The script will read the text in the Google
Document and convert it to speech using ChatGPT.



Here are some useful applications of the script to make a Google Document talk
to you:

 1. For people with visual impairments: The script can be used by people with
    visual impairments to listen to the contents of a Google Document instead of
    reading it. This can make it easier for them to access information and learn
    from written materials.
 2. Language learners: The script can be used by language learners to practice
    their listening skills. They can listen to a Google Document being read out
    loud and follow along with the text to improve their comprehension.
 3. Busy professionals: The script can be used by busy professionals who don’t
    have time to read a long document. They can listen to the document while
    doing other tasks, such as driving or exercising.
 4. Proofreading and editing: The script can be used to proofread and edit a
    Google Document. By listening to the text being read out loud, it can be
    easier to spot errors and make improvements.

In conclusion, making a Google Document talk to you using ChatGPT and Google
Apps Script is an easy process. By following the steps outlined in this article,
you can create your own script and listen to your Google Document instead of
reading it. This can be a great accessibility feature for people with visual
impairments or those who prefer listening to text instead of reading it.



Thank you for taking the time to read this! I hope you found it informative and
engaging. Let’s connect on Twitter. Happy Learning 😁✌️

Boost your Google Workspace potential with our e-book: Google Apps Script: A
Beginner’s Guide. Streamline your workflow and automate tasks today. Get your
copy now!

I’m available for freelance opportunities and you may reach out via email at
dilipkashyap.sd@gmail.com for further collaboration.





SIGN UP TO DISCOVER HUMAN STORIES THAT DEEPEN YOUR UNDERSTANDING OF THE WORLD.


FREE



Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.


Sign up for free


MEMBERSHIP



Access the best member-only stories.

Support independent authors.

Listen to audio narrations.

Read offline.

Join the Partner Program and earn for your writing.


Try for $5/month
AI
ChatGPT
Text To Speech
Artificial Intelligence
Productivity


2

2



Follow




WRITTEN BY DILIP KASHYAP

398 Followers
·Writer for

GoPenAI

My goal is to share solutions to the problems I have encountered during software
programming.

Follow





MORE FROM DILIP KASHYAP AND GOPENAI

Dilip Kashyap


HOW TO ADD GOOGLE SIGN IN BUTTON TO YOUR WEBSITE


HI FRIENDS,

3 min read·Sep 12, 2022

74





Lucas Scott

in

GoPenAI


PYTHON IS OUT OF FAVOR?HUGGING FACE OPEN-SOURCES A NEW ML FRAMEWORK WHICH
WRITTEN IN RUST


HUGGING FACE HAS QUIETLY OPEN SOURCED AN ML FRAMEWORK — CANDLE


·5 min read·Sep 26, 2023

566

6




Sanjay Singh

in

GoPenAI


A STEP-BY-STEP GUIDE TO TRAINING YOUR OWN LARGE LANGUAGE MODELS (LLMS).


LARGE LANGUAGE MODELS (LLMS) HAVE TRULY REVOLUTIONIZED THE REALM OF ARTIFICIAL
INTELLIGENCE (AI). THESE POWERFUL AI SYSTEMS, SUCH AS GPT-3…

10 min read·Sep 30, 2023

144

1




Dilip Kashyap


THE 10 BEST VS CODE EXTENSIONS IN 2023


IN THE FAST-EVOLVING LANDSCAPE OF SOFTWARE DEVELOPMENT, VISUAL STUDIO CODE (VS
CODE) EXTENSIONS HAVE BECOME INDISPENSABLE TOOLS…

5 min read·Nov 8, 2023

57




See all from Dilip Kashyap
See all from GoPenAI



RECOMMENDED FROM MEDIUM

Sangeeth Joseph - The AI dev


CREATE AN AI VOICE ASSISTANT USING PYTHON, WHISPER AI AND OPENAI API.


WITH THE RISE OF CHATGPT, I’VE ALWAYS BEEN CHATTING WITH IT TO QUENCH MY THIRST
FOR MORE KNOWLEDGE IN TERMS OF WEBDEVELOPMENT AND OTHER…

5 min read·Aug 26, 2023

68

1




Anish Singh Walia

in

𝐀𝐈 𝐦𝐨𝐧𝐤𝐬.𝐢𝐨


7 SECRET WEBSITES THAT PAY YOU TO WORK FROM ANYWHERE IN 2024 — PART 1


LOOKING FOR WEBSITES THAT PAY YOU TO WORK FROM ANYWHERE? CHECK OUT THESE 7
SECRET WEBSITES THAT OFFER REMOTE WORK OPPORTUNITIES IN 2024.

7 min read·Jan 10

2.5K

34





LISTS


CHATGPT PROMPTS

36 stories·1048 saves


CHATGPT

20 stories·426 saves


WHAT IS CHATGPT?

9 stories·283 saves


GENERATIVE AI RECOMMENDED READING

52 stories·664 saves


Soundar Pandiyan, Generalizing Specialist

in

IceApple Tech Talks


INTEGRATION WITH GOOGLE CALENDAR API USING SERVICE ACCOUNT

5 min read·Oct 7, 2023

97

1




David Oluyale


VIDEO TRANSCRIPTION USING ARTIFICIAL INTELLIGENCE PYTHON


VIDEOS ARE A POWERFUL MEDIUM FOR CONVEYING INFORMATION, BUT ADDING CAPTIONS OR
SUBTITLES CAN BE A TIME-CONSUMING TASK. IN THIS ARTICLE…

4 min read·Sep 24, 2023

2





Vishnu Sivan


BUILD YOUR OWN CHATGPT USING GOOGLE GEMINI API


WHILE THE AI LANDSCAPE HAS BEEN DOMINATED BY THE LIKES OF OPENAI AND MICROSOFT
COLLABORATIONS, GEMINI EMERGES AS A FORMIDABLE FORCE…

11 min read·Jan 2

508

9




Samuel Naesen

in

Bootcamp


14 BEST CUSTOM GPTS THAT WILL MAKE YOU MORE PRODUCTIVE IN 2024


UNLESS YOU’VE BEEN LIVING UNDER A ROCK FOR THE LAST FEW WEEKS, YOU PROBABLY
HEARD OF GPTS. HERE’S A LIST OF THE 14 BEST CUSTOM GTP’S THAT…

5 min read·Jan 17

24




See more recommendations

Help

Status

About

Careers

Blog

Privacy

Terms

Text to speech

Teams