Including text2speech dependency

THis is really helpful! I’m bit new to Anvil. How do you “add this app as a dependency”?? Thanks.

Hi @davidhdiskin,

In the case of this app:

  1. Clone the app with the link above.

  2. Select the app in your dependeny menu as shown in the screenshot:

There are other cases however, like anvil_extras (Indices and tables — Anvil Extras documentation) which you do not need to close and can acces directly as a “third party app” by entering the uid of the dependency.

Welcome to anvil by the way!

-Mark

EDIT:
To avoid confusion, this is the new editor 2.0 if you are using the old one your menu might look different.

1 Like

Thanks so much, Mark! The only problem I’ve run into so far is that the cloned text2speech app does not show up in my “Select a dependency” drop down. It may be it takes a bit of time to show up??

1 Like

Have you tried refreshing your page. That may work?

Great idea - that seems to have done it. Thanks.

Do let me know if you encounter any more issues with it.

Thanks so much for your help! So, I added text2speech as a dependency and gave it a package name of text2speech in the same dialog box under settings. Then, in my code did “import text2speech”. Then, called it as follows:
def speak(self,thetext):
self.text2speech.text=thetext
self.text2speech.start()

Got this error: AttributeError: ‘Form1’ object has no attribute ‘text2speech’ in that speak function.

What am I missing? Thanks!

This is telling you that there’s nothing on the form with the name text2speech, when you try self.text2speech.

In general, dependencies are not part of a form. You must import them, e.g. import text2speech and then use them like any other Python module, e.g. text2speech.text = thetext

I’ve gotten by that error. Now, in this function:
def speak(self,thetext):
text2speech.text=thetext
text2speech.start()

I get this error when it’s invoked:
AttributeError: module ‘text2speech’ has no attribute ‘start’

Yet, there is a start method in class text2speech. Do I need to create an instance first??

Thanks.

At this point you should be working from the example demo in the text2speech module. It looks like text2pseech is a form that you need to embed in your form. It looks like your original error was that you didn’t embed that form.

ok, Thanks much. So, you think class Demo is a form? Just curious how to tell that. Also, how do you embed one form into another? Thanks for all your help. David

When you click on Demo it shows the form in the IDE. You can also tell because of the icon that’s next to Demo in the list.

When you have included text2speech as a dependency in your app, and are editing a form in your app, look in the properties pane on the right. You’ll see a section for Custom Components, and should see a text2speech component. Drag that onto your form.

1 Like

Jay – thanks so much!! It is now working. David

2 Likes

Spoke too soon. Both my app and the demo app no longer speak. Wondering if this has to do with an account upgrade needed for Full Python support - needed for these apps??

I just ran the demo in a free account, and it worked fine. It sounds like your free account worked at one time, so I doubt that has anything to do with why it isn’t working now. Maybe check your browser’s console to see if there are Javascript errors?

This is starting to get too hard for me. I know virtually nothing about js but here is a screenshot of the js console attached.

Nothing jumps out at me there, but maybe someone who knows more about this library can comment.

Did you try different browsers, see if the text2speech library works in those?

Did you have it working at one point and it stopped, or did it never work?

Better to provide a clone link with the steps to reproduce your error. Make sure you tick include dependencies when sharing.

No, this dependency has nothing to do with the paid plan. As @stucork mentioned, a Clone Link will help.

Otherwise, please send any code snippets and tell more about the error you are facing.

1 Like

Here is the clone link: Anvil | Login

The app worked at first and speech worked fine. But, then, it stopped and no audio was produced. Definitely puzzled. Originally, trying to include dropdown for user to choose which voice, but when it stopped working, I just hard coded in “Alex” to keep it simpler.

Appreciate any help!! Thanks so much. David