do not save announcements to files anymore

This commit is contained in:
2025-03-04 13:44:38 +01:00
parent 1b48ade5d4
commit fc15604b8e
7 changed files with 133 additions and 39 deletions

View File

@@ -23,5 +23,26 @@ def resample_file(filename, out_filename, target_rate=int(24e3)):
log.info("Resampling of %s took %s s", os.path.basename(filename), round(time.time() - start, 3))
def resample_array(audio, rate, target_rate=int(24e3)):
start=time.time()
# Load the original audio file
if rate == target_rate: # Nothing to do
log.info('audio already at target rate, skipping resample')
return audio
# Convert the sample rate to target rate
resampled_audio = librosa.resample(audio, orig_sr=rate, target_sr=target_rate)
# Save the resampled audio as a new .wav file
log.info("Resampling took %s s", round(time.time() - start, 3))
return resampled_audio
if __name__ == "__main__":
resample_file('text_to_speech/welcome.wav', 'text_to_speech/welcome_resampled.wav')
import os
os.chdir(os.path.dirname(__file__))
file_dir = '../text_to_speech/'
resample_file(f'{file_dir}/welcome.wav', f'{file_dir}/welcome_resampled.wav')