Giter VIP home page Giter VIP logo

Comments (5)

mchinen avatar mchinen commented on May 18, 2024 1

An update: I've implemented the Hann window and tested on retrained models on our internal ViSQOL. For speech, there were some improvements in MSE (.57 to .50 for exponential model, .15 to .15 (unchanged) for lattice models) . For audio SVR models, the metrics did not change significantly for most audio samples (e.g. typically less than .05 MOS), but there are a few samples such as low bitrate music where the subjective score is low that have a significant change in estimated MOS.
Since this requires retraining speech models, I'll be pushing this out with the new models and a new set of conformance scores as a new ViSQOL version.

from visqol.

mchinen avatar mchinen commented on May 18, 2024

Great question. This change was implemented before I was involved, so I may be missing some context. However, this is my understanding. The gamamtone filterbank is used directly on the time domain signal instead of FFT. The gammatone signal is inherently windowed due to the shape of the gamma distribution, so unlike a regular STFT, windowing is not necessary. It may be good to confirm this with the original authors. See the image here for more info on the gammatone filterbank.
https://en.wikipedia.org/wiki/Gammatone_filter

from visqol.

shenberg avatar shenberg commented on May 18, 2024

I did some investigation into the matter.
I found a Python implementation of the same gammatone filter-bank, over at gammatone/filters.py and used it to create a python mock of the implementation in visqol, as best I understand it (main logic in gammatone_spectrogram.c). Results are worrying

import librosa
import librosa.display
import numpy as np
from gammatone.filters import centre_freqs, make_erb_filters

# from src/visqol_manager.cc
kNumBandsAudio = 32
kMinimumFreq = 50
kOverlap = 0.25
# from src/include/analysis_window.h
window_duration = 0.08

# compare src/equivalent_rectangular_bandwidth.cc to function make_erb_filters()
# they use the same constants and have similar logic, and seem based on 
# code written by Malcolm Slaney on June 11, 1998, including dividing the order-8 filter into 4 order-2 sections

fs = 48000
window_duration_samples = int(fs * window_duration)
hop_length_samples = int(fs * window_duration*kOverlap)

# python logic uses max frequency of fs / 2, exactly like in src/gammatone_spectrogram_builder.cc line 41
erb_frequencies = centre_freqs(fs, kNumBandsAudio, kMinimumFreq)
gammatone_filters = make_erb_filters(fs, erb_frequencies)


audio, _ = librosa.load(librosa.example('trumpet', hq=True), sr=fs)
# let's look at only 1 second
audio = audio[:fs]

windowed_audio = librosa.util.frame(audio, window_duration_samples, hop_length_samples)
# shape of windowed_audio is now (3840, 47) - 47 windows of 80ms overlapping by 75%

# for comparison's sake - we'll also use a window function
window = np.hanning(window_duration_samples)

output = np.zeros((filters.shape[0], windowed_audio.shape[1]), dtype=np.float32)
output_windowed = np.zeros((filters.shape[0], windowed_audio.shape[1]), dtype=np.float32)
for i in tqdm(range(windowed_audio.shape[1])):
   # calculate with no windowing
   filtered = erb_filterbank(windowed_audio[:, i], filters)
   output[:, i] = np.sum(filtered ** 2, axis=1)
   # calculate with windowing
   filtered = erb_filterbank(windowed_audio[:, i] * window, filters)
   output_windowed[:, i] = np.sum(filtered ** 2, axis=1)

# display log-power spectrograms, flip rows of outputs so low frequencies are at the bottom
fig, axes = plt.subplots(2,1, figsize=(8,8))
axes[0].set_title('No Window Function')
librosa.display.specshow(
   librosa.power_to_db(output[::-1], ref=np.max),
   ax=axes[0]
)
axes[1].set_title('Hanning Window')
librosa.display.specshow(
   librosa.power_to_db(output_windowed[::-1], ref=np.max),
   ax=axes[1]
)
plt.show()

The output as I run it on my system looks like this:
image
As far as I can tell, there are severe windowing artifacts in the gammatone spectrogram. A next step would be to check if this happens with the actual C++ code in VISQOL, though I see no reason for the results to be different. I hope this helps some.

from visqol.

mchinen avatar mchinen commented on May 18, 2024

That is a very nice analysis, thank you for that. I agree that we should look into this further. looked in the trumpet file and a log-frequency STFT does not have the vertical banding artifacts. With this evidence I'm inclined to think that the artifacts are in ViSQOL as well.

from visqol.

mchinen avatar mchinen commented on May 18, 2024

A fix for this was merged in #66.

from visqol.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.