ข้อมูลเสียงใน Python เบื้องต้น

Spoken Language Processing ด้วย Python

Daniel Bourke

Machine Learning Engineer/YouTube Creator

การจัดการไฟล์เสียงใน Python

  • ไฟล์เสียงมีหลายประเภท

    • mp3
    • wav
    • m4a
    • flac
  • เสียงดิจิทัลวัดด้วยความถี่การสุ่มตัวอย่าง (kHz)

    • 1 kHz = ข้อมูล 1,000 ชิ้นต่อวินาที
Spoken Language Processing ด้วย Python

ตัวอย่างความถี่การสุ่มตัวอย่าง

  • เพลงสตรีมมิงมีความถี่การสุ่มตัวอย่าง 32 kHz
  • หนังสือเสียงและคำพูดอยู่ระหว่าง 8 ถึง 16 kHz

  • เราไม่สามารถมองเห็นไฟล์เสียงได้ จึงต้องแปลงไฟล์ก่อน

import wave
Spoken Language Processing ด้วย Python

การเปิดไฟล์เสียงใน Python

  • ไฟล์เสียงบันทึกเป็น good-morning.wav
    # Import audio file as wave object
    good_morning = wave.open("good-morning.wav", "r")
    
# Convert wave object to bytes
good_morning_soundwave = good_morning.readframes(-1)
# View the wav file in byte form
good_morning_soundwave
b'\xfd\xff\xfb\xff\xf8\xff\xf8\xff\xf7\...
Spoken Language Processing ด้วย Python

การทำงานกับเสียงมีความแตกต่าง

  • ต้องแปลงเสียงให้เป็นรูปแบบที่ใช้งานได้
  • ตัวอย่างเสียงขนาดเล็ก = ข้อมูลจำนวนมาก
Spoken Language Processing ด้วย Python

มาฝึกกันเถอะ!

Spoken Language Processing ด้วย Python

Preparing Video For Download...