การทำงานกับข้อมูลเสียงใน 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...