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.
CodePudding user response:
- 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>