1

Hello I have made a code:

from gtts import gTTS
import os
import playsound
from pip._vendor.distlib.compat import raw_input
u = raw_input('type: ')

def player(textg):
    tts = gTTS(text = textg, lang='en')
    tts.save('name.mp3')
    playsound('name.mp3')
player(u)

An error comes that:

playsound('name.mp3')
TypeError: 'module' object is not callable

Please Help Me, i am using Python2.7.15

martineau
  • 119,623
  • 25
  • 170
  • 301

2 Answers2

2

You're importing the whole module, not a method within it.

You'd need to do something like

from playsound import playsound

case your method is called playsound

Filipe Aleixo
  • 3,924
  • 3
  • 41
  • 74
0

you should either import the specific method or call playsound method of the playsound module that you imported already:

playsound.playsound('name.mp3')
Yonas Kassa
  • 3,362
  • 1
  • 18
  • 27