Python Web App No Audio Output from FFmpeg

furstukin
FREE

4 months ago

I have a Flask web app I wrote using python that takes a user's input text and converts it to a list of mp3 files to play back the morse code audio of that text. I am using FFmpeg for the audio playback.

It works fine locally and in a Docker container on my local machine. But when I try it on Railway my debug statements tell me it is playing each file as intended but there is no audio I can hear.

I added debug statements to check for the stdout and stderr and they both return none.

This is the code that plays the mp3s

from data import MORSE_AUDIO_DICT
import subprocess
import time
import logging

logging.basicConfig(level=logging.DEBUG)

class MorseAudio:
    @classmethod
    def play_audio(cls, text_to_encode: str):
        for char in text_to_encode.lower():
            if char in MORSE_AUDIO_DICT:
                m_char = MORSE_AUDIO_DICT[char]
                audio_file = f'static/audio/morse_code/32-bit/{m_char}.mp3'
                logging.debug(f"Playing audio file: {m_char}.mp3") # Debug testing
                print(f"Playing audio file: {m_char}.mp3", flush=True)
                result = subprocess.run(["ffplay", "-nodisp", "-autoexit", audio_file], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
                print(result.stdout, flush=True)
                print(result.stderr, flush=True)
                time.sleep(0.05)  # Short delay after playback
            time.sleep(0.1)  # Delay between characters

And this is the log I get back

Playing audio file: s.mp3

Apr 01 12:58:04

web

DEBUG:root:Playing audio file: s.mp3

Apr 01 12:58:04

web

None

Apr 01 12:58:04

web

None

Apr 01 12:58:04

web

Playing audio file: o.mp3

Apr 01 12:58:04

web

DEBUG:root:Playing audio file: o.mp3

Apr 01 12:58:04

web

None

Apr 01 12:58:04

web

None

Apr 01 12:58:04

web

Playing audio file: s.mp3

Apr 01 12:58:04

web

DEBUG:root:Playing audio file: s.mp3

Apr 01 12:58:04

web

None

Apr 01 12:58:04

web

None

So, it appears to be working fine. Can anyone help me understand why there is no sound?

Closed

2 Replies

furstukin
FREE

4 months ago

Bump
Would really love to know if this is a limitation of Railway


4 months ago

Hey!

This is an issue with your project/application. Unfortunately, we're unable to offer first-party support for issues unrelated to the Railway product or platform.

Other communities such as Stackoverflow might be able to help you out further.

Best,
Brody


Status changed to Awaiting User Response Railway 4 months ago


Status changed to Closed brody 4 months ago