{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd\nimport wave\nimport torchaudio\nimport os\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory    \n    \n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-07-28T06:06:18.177440Z","iopub.execute_input":"2023-07-28T06:06:18.178080Z","iopub.status.idle":"2023-07-28T06:06:21.579033Z","shell.execute_reply.started":"2023-07-28T06:06:18.178015Z","shell.execute_reply":"2023-07-28T06:06:21.578063Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"\n","metadata":{"execution":{"iopub.status.busy":"2023-07-28T06:06:26.362022Z","iopub.execute_input":"2023-07-28T06:06:26.362583Z","iopub.status.idle":"2023-07-28T06:06:26.774111Z","shell.execute_reply.started":"2023-07-28T06:06:26.362554Z","shell.execute_reply":"2023-07-28T06:06:26.772872Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"import pydub\nimport pydub.playback\ndirectory='/kaggle/input/bengaliai-speech/train_mp3s/'\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory    \nfor filename in os.listdir(directory):\n    f = os.path.join(directory, filename)\n        # checking if it is a file\n    if os.path.isfile(f):        \n        audio_file = f\n        a = pydub.AudioSegment.from_mp3(f)\n        y = a.get_array_of_samples()\n        sr = a.frame_rate\n        # Returns array.array with interlaced left-right channels\n            # Convert to numpy and extract one channel\n        y = np.array(y)\n        df=pd.DataFrame(y).transpose()        \n        df.to_csv('train.csv', mode='a', index=False, header=False)\n        file=[]\n        file.append(filename)\n        print(filename)\n\n\n","metadata":{"execution":{"iopub.status.busy":"2023-07-28T10:02:04.828460Z","iopub.execute_input":"2023-07-28T10:02:04.828837Z","iopub.status.idle":"2023-07-28T10:02:08.192178Z","shell.execute_reply.started":"2023-07-28T10:02:04.828808Z","shell.execute_reply":"2023-07-28T10:02:08.190641Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"df1=pd.DataFrame(file)       \ndf1.to_csv('train1.csv',index=False, header=False)","metadata":{"execution":{"iopub.status.busy":"2023-07-28T10:02:15.642836Z","iopub.execute_input":"2023-07-28T10:02:15.643534Z","iopub.status.idle":"2023-07-28T10:02:15.650131Z","shell.execute_reply.started":"2023-07-28T10:02:15.643502Z","shell.execute_reply":"2023-07-28T10:02:15.649118Z"},"trusted":true},"execution_count":null,"outputs":[]}]}