main.py 579 B

123456789101112131415
  1. #!/usr/bin/env python3
  2. from audio_recorder import AudioRecorder
  3. from nicegui import ui
  4. with ui.row().classes('w-full justify-center'):
  5. audio_recorder = AudioRecorder(on_audio_ready=lambda data: ui.notify(f'Recorded {len(data)} bytes'))
  6. with ui.row().classes('w-full justify-center'):
  7. ui.button('Play', on_click=audio_recorder.play_recorded_audio) \
  8. .bind_enabled_from(audio_recorder, 'recording')
  9. ui.button('Download', on_click=lambda: ui.download(audio_recorder.recording, 'audio.ogx')) \
  10. .bind_enabled_from(audio_recorder, 'recording')
  11. ui.run()