Getting Error: Exception: spectrogram to big. size 2218

  Uncategorised

I get this error while trying to add more chars into my charmap.(see code)

It would be really nice if some of you guys know how to fix this error:)

I’m grateful for every help I can get because this error is starting to make me kinda crazy

Full error message:

  File "C:Python Programmsneuralnetdataset.py", line 119, in __getitem__
    raise Exception('spectrogram to big. size %s'%spectrogram.shape[2])
Exception: spectrogram to big. size 2218

Source code:

import torch

class TextProcess:
    def __init__(self):
        char_map_str = """
        ' 0
        <SPACE> 1
        a 2
        b 3
        c 4
        d 5
        e 6
        f 7
        g 8
        h 9
        i 10
        j 11
        k 12
        l 13
        m 14
        n 15
        o 16
        p 17
        q 18
        r 19
        s 20
        t 21
        u 22
        v 23
        w 24
        x 25
        y 26
        z 27
        ####the following chars are the ones I try to add####
        ä 28
        ö 29
        ü 30
        . 31
        , 32
        - 33
        _ 34
        """
        self.char_map = {}
        self.index_map = {}
        for line in char_map_str.strip().split('n'):
            ch, index = line.split()
            self.char_map[ch] = int(index)
            self.index_map[int(index)] = ch
        self.index_map[1] = ' '

    def text_to_int_sequence(self, text):
        """ Use a character map and convert text to an integer sequence """
        int_sequence = []
        for c in text.lower():
            if c == ' ':
                ch = self.char_map['<SPACE>']
            else:
                ch = self.char_map[c]
            int_sequence.append(ch)
        return int_sequence

    def int_to_text_sequence(self, labels):
        """ Use a character map and convert integer labels to an text sequence """
        string = []
        for i in labels:
            string.append(self.index_map[i])
        return ''.join(string).replace('<SPACE>', ' ')

textprocess = TextProcess()

def GreedyDecoder(output, labels, label_lengths, blank_label=28, collapse_repeated=True):
    arg_maxes = torch.argmax(output, dim=2)
    decodes = []
    targets = []
    for i, args in enumerate(arg_maxes):
        decode = []
        targets.append(textprocess.int_to_text_sequence(
                labels[i][:label_lengths[i]].tolist()))
        for j, index in enumerate(args):
            if index != blank_label:
                if collapse_repeated and j != 0 and index == args[j -1]:
                    continue
                decode.append(index.item())
        decodes.append(textprocess.int_to_text_sequence(decode))
    return decodes, targets

Thank’s for every help in advance!

Source: Visual Studio Questions

LEAVE A COMMENT