I am creating a Bash program using Replit and it needs to play sound. What should I do? I surfed through the docs but they were of no use.
Asked
Active
Viewed 71 times
0
-
1[Under what circumstances may I add “urgent” or other similar phrases to my question?](https://meta.stackoverflow.com/questions/326569/under-what-circumstances-may-i-add-urgent-or-other-similar-phrases-to-my-quest) (hint: never) – tripleee May 09 '22 at 11:37
-
The link in my first comment already explains adequately how this is irrelevant to those who are willing to help you. I'm guessing you didn't read it, so I will now explain that the reason I included a link was to provide you with enough context and background to solve this matter without the need for further discussions or handholding. – tripleee May 10 '22 at 09:03
2 Answers
0
- Create a secret called
VNC_ENABLE_EXPERIMENTAL_AUDIO
with a value of 1 - Trigger the VNC screen by opening a native desktop window like xeyes in the background
- Create your audio
- Tick the checkbox at the bottom right corner of the VNC view
Steps 3 and 4 are interchangable, but to play sound browsers require a user interaction and Replit solves it this way.
Example replit.nix file
{ pkgs }: {
deps = [
pkgs.bashInteractive
pkgs.speechd
pkgs.xlibs.xeyes
];
}
Example main.sh file
{ pkgs }: {
deps = [
pkgs.bashInteractive
pkgs.speechd
pkgs.xlibs.xeyes
];
}
Resulting Replit (requires CORS JS iframe embeds)
<iframe src="https://replit.com/@cachius/AudioInBash?lite=1&outputonly=1" style="position: absolute; height: 100%; width: 100%; border: none"></iframe>

cachius
- 1,743
- 1
- 8
- 21
-
1I tried this but since we need to check the checkbox at the bottom right, I thought it was useless. But since it's the only way now, thanks! – May 10 '22 at 08:47
-
@anonymous Actually it's pretty mind-boggling this is possible at all, via VNC in the browser! [Requiring user interaction](/q/50490304) for audio is browser policy to prevent ads from annoying too much. What Replit could do is integrate better with the VNC viewer so that clicking on it enables audio automatically. You could suggest this to them – cachius May 10 '22 at 09:37
-
0
Put
audio = true
into the .replit file

Help
- 1
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 12 '22 at 12:48