Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,18 +9,25 @@ import io
|
|
| 9 |
import glob
|
| 10 |
import shutil
|
| 11 |
|
| 12 |
-
#
|
| 13 |
RECORDING_ENABLED = False
|
| 14 |
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
|
| 25 |
def get_binary_file_downloader_html(bin_file, file_label='File'):
|
| 26 |
"""Generate a link to download the given file."""
|
|
@@ -52,6 +59,9 @@ def main():
|
|
| 52 |
st.markdown("### Convert monophonic audio to sheet music")
|
| 53 |
|
| 54 |
# Initialize session state for recording
|
|
|
|
|
|
|
|
|
|
| 55 |
if RECORDING_ENABLED:
|
| 56 |
if 'recorder' not in st.session_state:
|
| 57 |
st.session_state.recorder = AudioRecorder()
|
|
|
|
| 9 |
import glob
|
| 10 |
import shutil
|
| 11 |
|
| 12 |
+
# Global flag for recording capability
|
| 13 |
RECORDING_ENABLED = False
|
| 14 |
|
| 15 |
+
def init_recording():
|
| 16 |
+
global RECORDING_ENABLED
|
| 17 |
+
# Import with error handling for Hugging Face Spaces
|
| 18 |
+
try:
|
| 19 |
+
from transcriber import AudioTranscriber
|
| 20 |
+
from hf_transcriber import HFTranscriber
|
| 21 |
+
from recorder import AudioRecorder, list_audio_devices
|
| 22 |
+
RECORDING_ENABLED = True
|
| 23 |
+
return True
|
| 24 |
+
except ImportError as e:
|
| 25 |
+
st.warning(f"Some features may be limited: {str(e)}")
|
| 26 |
+
RECORDING_ENABLED = False
|
| 27 |
+
return False
|
| 28 |
+
|
| 29 |
+
# Initialize recording capability
|
| 30 |
+
init_recording()
|
| 31 |
|
| 32 |
def get_binary_file_downloader_html(bin_file, file_label='File'):
|
| 33 |
"""Generate a link to download the given file."""
|
|
|
|
| 59 |
st.markdown("### Convert monophonic audio to sheet music")
|
| 60 |
|
| 61 |
# Initialize session state for recording
|
| 62 |
+
if 'recording_initialized' not in st.session_state:
|
| 63 |
+
st.session_state.recording_initialized = False
|
| 64 |
+
|
| 65 |
if RECORDING_ENABLED:
|
| 66 |
if 'recorder' not in st.session_state:
|
| 67 |
st.session_state.recorder = AudioRecorder()
|