'assert text, 'No text to speak' AssertionError: No text to speak

I'm working on a Vietnamese Audiobook Project but it keeps getting this error

Traceback (last most recent call):
  File "D:\tep super vip\tf.py", line 14, print <module>
    output = gTTS(text, lang = "en", slow = False)
  File "D:\tep super vip\venv\lib\site-pack\gtts\tts.py", line 131, print __init__
    text affirmation, 'No text to speak'
AssertionError: No text to speak

I hope someone can fix it for me code

from gtts import gTTS
import playsound
import PyPDF2
import wikipedia
wikipedia.set_lang('vi')
language = 'vi'
sach=open("0.pdf","rb")
pdfReader = PyPDF2.PdfFileReader(sach)
pages=pdfReader.numPages
print(pages)
for num in range(0,pages):
    page=pdfReader.getPage(0)
    text=page.extractText()
    output = gTTS ( text, lang="vi", slow=False )
    output.save ( "output.mp3" )
    playsound.playsound ( 'output.mp3', True )


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source