mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Update melSpectrogram
This commit is contained in:
parent
f1ff995cc7
commit
a88bd5c820
@ -256,6 +256,8 @@ class DownloadActivity : ComponentActivity() {
|
|||||||
|
|
||||||
private val themeOption: MutableState<ThemeOption?> = mutableStateOf(null)
|
private val themeOption: MutableState<ThemeOption?> = mutableStateOf(null)
|
||||||
private fun updateContent() {
|
private fun updateContent() {
|
||||||
|
// TODO: In some cases seems to cause a crash?
|
||||||
|
// May be related https://github.com/mozilla-mobile/focus-android/issues/7712
|
||||||
setContent {
|
setContent {
|
||||||
themeOption.value?.let { themeOption ->
|
themeOption.value?.let { themeOption ->
|
||||||
val themeIdx = useDataStore(key = THEME_KEY.key, default = themeOption.key)
|
val themeIdx = useDataStore(key = THEME_KEY.key, default = themeOption.key)
|
||||||
|
@ -209,7 +209,7 @@ class AudioFeatureExtraction(
|
|||||||
* This function converts input audio samples to 1x80x3000 features
|
* This function converts input audio samples to 1x80x3000 features
|
||||||
*/
|
*/
|
||||||
fun melSpectrogram(y: DoubleArray): FloatArray {
|
fun melSpectrogram(y: DoubleArray): FloatArray {
|
||||||
val paddedWaveform = DoubleArray(min(numSamples, y.size + hopLength)) {
|
val paddedWaveform = DoubleArray(min(numSamples, y.size + hopLength).coerceAtLeast(nFFT)) {
|
||||||
if (it < y.size) {
|
if (it < y.size) {
|
||||||
y[it]
|
y[it]
|
||||||
} else {
|
} else {
|
||||||
|
@ -12,11 +12,5 @@ private val extractor = AudioFeatureExtraction(
|
|||||||
)
|
)
|
||||||
|
|
||||||
fun extractMelSpectrogramForWhisper(samples: DoubleArray): FloatArray {
|
fun extractMelSpectrogramForWhisper(samples: DoubleArray): FloatArray {
|
||||||
val paddedSamples = if(samples.size <= 640) {
|
return extractor.melSpectrogram(samples)
|
||||||
samples + DoubleArray(640) { 0.0 }
|
|
||||||
} else {
|
|
||||||
samples
|
|
||||||
}
|
|
||||||
|
|
||||||
return extractor.melSpectrogram(paddedSamples)
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user