1.3.1 Updates

- Add startup and network failure sound effects
- 12864 OLED scroll text
- Internalization of volume actions
This commit is contained in:
Terrence
2025-03-03 07:29:22 +08:00
parent 36d98ce1a4
commit 7945da0c84
30 changed files with 217 additions and 104 deletions

View File

@@ -8,19 +8,27 @@ import numpy as np
def encode_audio_to_opus(input_file, output_file):
# Load audio file using librosa
audio, sample_rate = librosa.load(input_file, sr=None, mono=False, dtype=np.int16)
audio, sample_rate = librosa.load(input_file, sr=None, mono=False, dtype=np.float32)
# Convert sample rate to 16000Hz if necessary
target_sample_rate = 16000
if sample_rate != target_sample_rate:
audio = librosa.resample(audio, orig_sr=sample_rate, target_sr=target_sample_rate)
sample_rate = target_sample_rate
# Get left channel if stereo
if audio.ndim == 2:
audio = audio[0]
# Convert audio data back to int16 after resampling
audio = (audio * 32767).astype(np.int16)
# Initialize Opus encoder
encoder = opuslib.Encoder(sample_rate, 1, opuslib.APPLICATION_VOIP)
# Encode audio data to Opus packets
# Save encoded data to file
with open(output_file, 'wb') as f:
sample_rate = 16000 # 16000Hz
duration = 60 # 60ms every frame
frame_size = int(sample_rate * duration / 1000)
for i in tqdm.tqdm(range(0, len(audio) - frame_size, frame_size)):

View File

@@ -52,6 +52,18 @@ def generate_header(input_path, output_path):
static_cast<const char*>(p3_{base_name}_start),
static_cast<size_t>(p3_{base_name}_end - p3_{base_name}_start)
}};''')
# 生成公共音效
for file in os.listdir(os.path.join(os.path.dirname(output_path), 'common')):
if file.endswith('.p3'):
base_name = os.path.splitext(file)[0]
sounds.append(f'''
extern const char p3_{base_name}_start[] asm("_binary_{base_name}_p3_start");
extern const char p3_{base_name}_end[] asm("_binary_{base_name}_p3_end");
static const std::string_view P3_{base_name.upper()} {{
static_cast<const char*>(p3_{base_name}_start),
static_cast<size_t>(p3_{base_name}_end - p3_{base_name}_start)
}};''')
# 填充模板
content = HEADER_TEMPLATE.format(

4
scripts/release.py Normal file → Executable file
View File

@@ -106,6 +106,10 @@ def release(board_type, board_config):
f.write("\n")
for append in sdkconfig_append:
f.write(f"{append}\n")
# Build with macro BOARD_NAME defined to name
if os.system(f"idf.py -DBOARD_NAME={name} build") != 0:
print("build failed")
sys.exit(1)
# Call merge-bin
if os.system("idf.py merge-bin") != 0:
print("merge-bin failed")