導入 Python Packages
(in main.py)
9 from pydub import AudioSegment
10 from pydub.silence import split_on_silence
11
12 # [START speech_quickstart]
13 import io
14 import os
15 import numpy as np
16 import pandas as pd
17 import glob
18
19 # Imports the Google Cloud client library
20 # [START migration_import]
21 from google.cloud import speech
22 from google.cloud.speech import enums
23 from google.cloud.speech import types
24 # [END migration_import]
pydub
[1]是針對audio processing的module
The io
[2] module provide Python's main facilities for dealing with various types of I/O. There are three main types of I/O: text I/O, binary I/O and raw I/O. A concrete object belonging to any of these categories is called file object. Other common terms are stream and file-like object.
The os
[3] module provides a portable way of using operating system dependent functionality.
numpy
[4] 是Python一個重要的模組,主要用於資料處理。numpy
底層以C和Fortran語言實作,能夠快速操作多重維度的陣列。當Python處理龐大資料時,原生list效能表現不理想(但可以動態存異質資料),而numpy
具備平行處理能力,可以將操作一次套用在大型陣列上。另外Python其餘重量級資料科學套件(eg.. Pandas, Scipy, Scikit-learn等)都是奠基在numpy
的基礎上。
pandas
[5] 是python一個數據分析的package,2009年底開源,提供高效能、簡易使用的資料格式(Data Frame)讓使用者可以快速操作及分析資料。pandas取名字pan(el)-da(ta)-s,也與套件提供的三個資料結構 Panel
、DataFrame
、Series
相呼應[6]。
glob
是找尋符合特定命名規則pathnames的module。
google.cloud.speech
, google.cloud.speech.enums
,
google.cloud.speech.types
都是Google Cloud Speech-to-text service提供的package。
[1] https://github.com/jiaaro/pydub
[2] https://docs.python.org/3/library/io.html
[3] https://docs.python.org/3/library/os.html
[4] https://blog.techbridge.cc/2017/07/28/data-science-101-numpy-tutorial/
[5] https://oranwind.org/python-pandas-ji-chu-jiao-xue/
[6] https://medium.com/datainpoint/從-pandas-開始-python-與資料科學之旅-8dee36796d4a