2

I have a view which takes text from a form and uses python-espeak to turn the input into speech. This only works the first time the view is used, afterwards espeak does not produce anything. I think the issue is with espeak not resetting somehow, since I can still hear static afterwards as if espeak is still running, although that goes away and doesn't come back on the second form entry. Why does espeak fail to work the second time?

@app.route('/', methods=['GET', 'POST'])
def index():
    if request.method == 'POST':
        message = request.form['tts']
        espeak.synth(message)
        return redirect(url_for('index'))

    return render_template('index.html')
<form method="post">
  <input name="tts">
  <input type="submit">
</form>
davidism
  • 121,510
  • 29
  • 395
  • 339
zigarot
  • 21
  • 2
  • after tidying up the code, adding the redirect as you mentioned (simply return redirect('/'), It's working great, but the form no longer calls the espeak action, I'm beginning to think the issue is with espeak not resetting somehow, since i can still hear the static afterwards as if espeak is still running, although that goes away and doesn't come back on the second form entry. Guess I'll fork my googleFu :D – zigarot May 22 '16 at 07:33
  • I'm using python-espeak with python3 The espeak parts works great, i can call espeak multiple times in the one page, but as soon as I redirect(refresh form), when i sumbit the form again, the static (you can kind of hear it when espeak is running, it sounds like static) stops, and no more tts messages are sent. The server works, it would seem, but nothing comes to the TTS. I guess I could try to find logs somewhere... – zigarot May 23 '16 at 08:27
  • done. the redirect was not the problem. by some amazing coincidence I found a website [here](https://hackaday.io/project/9012/instructions) that had exactly what I was trying to do. The problem with my code was that espeak was not closing connection when it finished speaking, so did not initialise correctly when it reloaded. By putting in the extra python script for espeak, I fixed it completely. Thanks. – zigarot May 23 '16 at 13:11

0 Answers0