fffiloni commited on
Commit
10c0809
·
verified ·
1 Parent(s): 37217db

Update converter.py

Browse files
Files changed (1) hide show
  1. converter.py +9 -0
converter.py CHANGED
@@ -45,6 +45,15 @@ def dynamic_range_decompression_torch(x, C=1):
45
 
46
 
47
  def spectral_normalize_torch(magnitudes):
 
 
 
 
 
 
 
 
 
48
  output = dynamic_range_compression_torch(magnitudes)
49
  return output
50
 
 
45
 
46
 
47
  def spectral_normalize_torch(magnitudes):
48
+ """
49
+ Apply dynamic range compression while avoiding issues with very low values
50
+ """
51
+ # Apply boost if needed based on the mean of the magnitudes
52
+ spec_mean = magnitudes.mean()
53
+ if spec_mean < -5.0:
54
+ print(f"⚠️ Spectrogram mean is too low (Mean: {spec_mean}). Applying boost!")
55
+ magnitudes = magnitudes * 2.0 # Boost the spectrogram values to prevent them from getting too low
56
+
57
  output = dynamic_range_compression_torch(magnitudes)
58
  return output
59