0

I have an audio file, speech.mp3 which I generate from :

@game_views.route('/loadGame', methods=['POST'])
def game_page():
    result = request.form.get('gameChoice')
    word = getWordList(result)
    language = 'en'
    output = gTTS(text=word, lang=language, slow=False)
    output.save("speech.mp3")
  
    #playsound("speech.mp3")
    return render_template("game.html", result=result, word=word, sound=output)

In my game.html template, however, I would like to play the word that I was about to randomly get. I am unsure how to do this. So far, I have tried :

{% block content %}
{% if current_user.is_authenticated %}

<h3> Hi {{ current_user.username }}! </h3>

  <h4> Difficulty: {{result}} </h4>
  <br>
  <h4> Word: {{word}} </h4>

    <audio src="speech.mp3" controls></audio>

  {% endif %}
{% endblock %}

Any help would be greatly appreciated on how to do this task.

bxia
  • 9
  • 1
  • Is your goal to use python with the `playsound` module, or use html? – Anonymous Apr 06 '22 at 21:53
  • @Anonymous4045 I tried to use the playsound module but it was not working out or I should more say I was not sure how to get it to play on the HTML page (template) – bxia Apr 06 '22 at 22:02

0 Answers0