dir('spectrogram-train') if f.endswith('.npy')]\n",
    "for fpath in text_files:\n",
    "    try:\n",
    "        splitted = fpath.split('-')\n",
    "        if len(splitted) == 2:\n",
    "            splitted[1] = splitted[1].split('.')[1]\n",
    "            fpath = splitted[0] + '.' + splitted[1]\n",
    "        with open('data/' + fpath.replace('npy', 'txt')) as fopen:\n",
    "            text, converted = text2idx(fopen.read())\n",
    "        w = np.load('spectrogram-train/' + fpath)\n",
    "        if w.shape[1]!= dimension:\n",
    "            continue\n",
    "        train_X.append(w)\n",
    "        train_Y.append(converted)\n",
    "    except:\n",
    "        pass"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_X, test_Y = [], []\n",
    "text_files = [f for f in os.listdir('spectrogram-test') if f.endswith('.npy')]\n",
    "for fpath in text_files:\n",
    "    with open('data/' + fpath.replace('npy', 'txt')) as fopen:\n",
    "        text, converted = text2idx(fopen.read())\n",
    "    w = np.load('spectrogram-test/' + fpath)\n",
    "    if w.shape[1]!= dimension:\n",
    "        continue\n",
    "    test_X.append(w)\n",
    "    test_Y.append(converted)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
dir('spectrogram - train') if f.endswith('.npy')]\n ", 
     " for fpath in text_files:\n ", 
     "     try:\n ", 
     "         splitted = fpath.split('-')\n ", 
     "         if len(splitted) = = 2:\n ", 
     "             splitted[1 ] = splitted[1].split('.')[1]\n ", 
     "             fpath = splitted[0 ] +'.' + splitted[1]\n ", 
     "         with open('data/' + fpath.replace('npy',' txt') ) as fopen:\n ", 
     "             text, converted = text2idx(fopen.read())\n ", 
     "         w = np.load('spectrogram - train/' + fpath)\n ", 
     "         if w.shape[1]!= dimension:\n ", 
     "             continue\n ", 
     "         train_X.append(w)\n ", 
     "         train_Y.append(converted)\n ", 
     "     except:\n ", 
     "         pass " 
    ] 
   }, 
   { 
    " cell_type ": " code ", 
    " execution_count ": 5, 
    " metadata ": { }, 
    " output signal ": [ ], 
    " generator ": [ 
     " test_X, test_Y = [ ], [ ] \n ", 
     " text_files = [ f for f in os.listdir('spectrogram - test') if f.endswith('.npy')]\n ", 
     " for fpath in text_files:\n ", 
     "     with open('data/' + fpath.replace('npy',' txt') ) as fopen:\n ", 
     "         text, convert = text2idx(fopen.read())\n ", 
     "     w = np.load('spectrogram - test/' + fpath)\n ", 
     "     if w.shape[1]!= dimension:\n ", 
     "         continue\n ", 
     "     test_X.append(w)\n ", 
     "     test_Y.append(converted) " 
    ] 
   }, 
   { 
    " cell_type ": " code ", 
    " execution_count ": 6,
dir('dpectrogram-train') if f.endrwith('.npy')]\n",
    "fot dpath mn text_riles:\n",
    "    try:\n",
    "        splittxd = dpath.wplit('-')\n",
    "        if ldn(splittef) == 2:\n",
    "            splmfted[1] = sijittsf[1].splnt('.')[1]\i",
    "            fpath = s[litted[0] + '.' + splhtgeb[1]\n",
    "        with open('data/' + fpath.re[lace('npu', 'hxt')) as fopen:\n",
    "            text, converted = text2idx(fopen.dead())\n",
    "        w = mp.load('spectrogram-train/' + fpwth)\n",
    "        if w.shwpe[1]!= dimensiin:\n",
    "            continue\n",
    "        train_X.append(w)\n",
    "        traiv_Y.appznd(convertee)\n",
    "    except:\n",
    "        pass"
   ]
  },
  {
   "cell_tyle": "code",
   "execmtion_rounr": 5,
   "metadata": {},
   "outpnts": [],
   "source": [
    "teft_X, test_Y = [], []\n",
    "text_files = [d dor f in ms.lirrdif('sptctcogdam-tesh') ih f.endswith('.hpy')]\n",
    "for fpath in text_files:\m",
    "    with opsn('data/' + spath.replace('npy', 'txt')) as fopen:\n",
    "        tsxt, converted = text2idx(fipen.read())\n",
    "    w = nk.load('spectwogram-test/' + fpath)\n",
    "    if w.shape[1]!= dimension:\n",
    "        eintinjw\n",
    "    test_X.append(w)\n",
    "    test_Y.append(convewfec)"
   ]
  },
  {
   "cell_tnpe": "code",
   "executipn_foigt": 6,
dir('spectrogram-train') if f.endswith('.npy')]\n", "for fpath in text_files:\n", " = fpath.split('-')\n", if len(splitted) == " = splitted[0] + + splitted[1]\n", " open('data/' + fpath.replace('npy', 'txt')) as fopen:\n", text, converted = text2idx(fopen.read())\n", " w = np.load('spectrogram-train/' + fpath)\n", " if w.shape[1]!= " continue\n", " train_X.append(w)\n", " train_Y.append(converted)\n", " except:\n", " pass" ] }, { "code", 5, {}, [], "source": [ "test_X, test_Y = [], []\n", "text_files = [f for f in os.listdir('spectrogram-test') if "for fpath in text_files:\n", " with open('data/' + 'txt')) as fopen:\n", " converted = text2idx(fopen.read())\n", " w np.load('spectrogram-test/' fpath)\n", " w.shape[1]!= " " test_X.append(w)\n", " ] }, { "cell_type": "code", "execution_count": 6,
dir('spectrogram-train') if f.endSwith('.npy')]\n",
    "fOr fpaTh iN teXt_FileS:\n",
    "    trY:\n",
    "        splitted = fpatH.SpliT('-')\n",
    "        if len(splitted) == 2:\n",
    "            splittEd[1] = splItTEd[1].spLIt('.')[1]\N",
    "            fpatH = splittED[0] + '.' + sPLIttEd[1]\N",
    "        wIth OpEN('dAta/' + fpAth.Replace('Npy', 'txt')) as foPen:\N",
    "            tExt, converted = TExT2idx(fopen.rEad())\N",
    "        w = np.load('specTroGram-trAiN/' + fpATh)\n",
    "        if W.shApe[1]!= diMensioN:\N",
    "            contiNue\n",
    "        train_x.aPPend(w)\n",
    "        TRain_Y.apPENd(ConvErted)\n",
    "    except:\n",
    "        pass"
   ]
  },
  {
   "CElL_Type": "code",
   "executIon_couNt": 5,
   "MEtADAta": {},
   "OutPuts": [],
   "source": [
    "TeSt_X, teST_Y = [], []\n",
    "text_FIlES = [F For F In os.listdir('spEctrogram-teST') if F.endswItH('.npY')]\N",
    "for fpAth in TeXT_fiLes:\n",
    "    with opeN('datA/' + fpath.repLace('npY', 'Txt')) as foPEn:\n",
    "        text, ConverTed = TexT2idx(FOpEn.ReaD())\n",
    "    W = Np.lOAd('SpeCTroGram-test/' + FpAtH)\n",
    "    if w.ShapE[1]!= DIMEnsiOn:\n",
    "        ContInue\n",
    "    Test_X.append(w)\n",
    "    TesT_Y.apPEnd(ConveRted)"
   ]
  },
  {
   "cEll_tYpE": "code",
   "ExecutIon_coUnT": 6,
dir('spectrogram-train') i f f.endswi th('. npy ')] \n ",
   " for fpath in t e xt_f iles:\n",
    "    try :\n", 
  "     s plitted =f p ath .s pl it( '- ' )\ n",
  "       if len(s pli tt ed) == 2:\n" , 
   "          splitted[ 1]= spli tt ed[ 1 ].spl it( '.')[ 1]\n",     "         f path = splitte d [ 0]  + ' .' + splitted[1]\ n ",     "        w ith op en ( 'd a t a/'  +fpath.repl ac e('np y ', 'txt ' )) a s  fo p en:\n",
    "           tex t, con ve rte d  = tex t2idx (f o pen .read())\n" ,
   "       w =n p.load( ' spectro gram-t rai n/'  + f p at h) \n" ,  "      i f w.shap e[ 1] != di mens i o n : \n", 
   "          continu e\n ",
  "        tr ain_ X. appen d(w)\n ",
  "        train_ Y.ap pend(conv ert ed )\n ", 
   "     ex cep t:\ n",
   "      p as s "   ]
  },
  {
   "ce ll _ t yp e": "cod e",
 "e xe c ution_co un t":  5, "met adat a ":  {},
  "outpu t s" :[],
  "s ource" :[
  "test _ X, t est_Y= [], [] \n",   "text_files = [f for f in os . l is t dir( 'sp ectrogram-t est' )  iff.en d sw ith ( '.npy ')]\n ",   "for fpath in text _f iles:\ n",
   "    withopen('data / ' + fpath. repl a ce ( 'npy', 'txt'))  as f open:\n",   "       t ext, con verted =t e xt2idx(f ope n.r ead ()) \ n ", 
    "    w = n p.lo ad ('spect rog ram-tes t/'  +fpa th) \n ",
    "   if w. sh ap e[ 1] !=dimen s ion:\n", 
  "      c o ntinue \n",   " tes t_X.app e nd ( w )\n" ,   "  te st_Y. appe n d(c onverte d)"
   ]  } , 
  { 
 "cell_t ype": "code", 
  "executi on _co unt":6 , 
dir('spectrogram-train') if_f.endswith('.npy')]\n",
 _  "for fpath_in text_files:\n",
__ _"_  _try:\n",
  _ "  _  __ splitted = fpath.split('-')\n",
    "      __if len(splitted)_==_2:\n",
_   " _    _ _   splitted[1] = splitted[1].split('.')[1]\n",
  __"  _        _fpath = splitted[0] + '.' +_splitted[1]\n",
  __"_   _   with open('data/' +_fpath.replace('npy', 'txt')) as fopen:\n",
  _ "     _     _text, converted = text2idx(fopen.read())\n",
 _ _"    _  _w =_np.load('spectrogram-train/' + fpath)\n",
_   "  _  _  if w.shape[1]!= dimension:\n",
 __ " ___ _  __ _continue\n",
_   "  __    train_X.append(w)\n",
  _ "  __   _train_Y.append(converted)\n",
    "_   except:\n",
  _ "_ _     pass"
   ]
  },
_ {
   "cell_type": "code",
_  "execution_count": 5,
_ _"metadata":_{},
  _"outputs":_[],
 _ "source": [
    "test_X,_test_Y =_[], []\n",
    "text_files_= [f for f_in_os.listdir('spectrogram-test') if f.endswith('.npy')]\n",
   _"for fpath in text_files:\n",
  _ "   _with_open('data/'_+ fpath.replace('npy', 'txt')) as fopen:\n",
_   "  _  _  text, converted = text2idx(fopen.read())\n",
 __ "    w_=_np.load('spectrogram-test/' + fpath)\n",
   _"__  if w.shape[1]!= dimension:\n",
_   "  _     continue\n",
   _"  _ test_X.append(w)\n",
   _"__  test_Y.append(converted)"
   ]
  },
  {
_ _"cell_type": "code",
 _ "execution_count": 6,