I created a hand tracking program in Python. I wrote the following code for a local Streamlit environment. It worked fine when I ran it locally.
This is the audio signal generation part.
def generate_tone(frequency, volume=0.5, sample_rate=44100, duration=0.1):
t = np.linspace(0, duration, int(sample_rate * duration), endpoint=False)
return volume * np.sin(2 * np.pi * frequency * t)
This is the sound playback part.
tone = generate_tone(frequency=freq, duration=0.2, volume=bolm)
sd.play(tone, samplerate=44100)
sd.wait()
I tried to publish the above code as is on StreamlitCloud. However, it seemed like the sounddevice module wasn’t working, so I rewrote it as shown below. As a result, perhaps due to browser settings (?), no sound was produced.
This is the sound playback part.
components.html(“”"
“”", height=0, width=0)
def generate_tone(freq, vol):
components.html(f"“, height=0, width=0)
def stop_tone():
components.html(”", height=0, width=0)
This is the calling part.
generate_tone(freq, vol)
I’m trying to create a professional program that captures video from a webcam and changes the pitch and volume based on hand movements. Is this possible with StreamlitCloud?