introd u ction to a u dio data in p y thon
play

Introd u ction to a u dio data in P y thon SP OK E N L AN G U AG E - PowerPoint PPT Presentation

Introd u ction to a u dio data in P y thon SP OK E N L AN G U AG E P R OC E SSIN G IN P YTH ON Daniel Bo u rke Machine Learning Engineer / Yo u T u be Creator Dealing w ith a u dio files in P y thon Di erent kinds all of a u dio les mp


  1. Introd u ction to a u dio data in P y thon SP OK E N L AN G U AG E P R OC E SSIN G IN P YTH ON Daniel Bo u rke Machine Learning Engineer / Yo u T u be Creator

  2. Dealing w ith a u dio files in P y thon Di � erent kinds all of a u dio � les mp 3 w a v m 4 a � ac Digital so u nds meas u red in freq u enc y ( kH z) 1 kH z = 1000 pieces of information per second SPOKEN LANGUAGE PROCESSING IN PYTHON

  3. Freq u enc y e x amples Streaming songs ha v e a freq u enc y of 32 kH z A u diobooks and spoken lang u age are bet w een 8 and 16 kH z We can ' t see a u dio � les so w e ha v e to transform them � rst import wave SPOKEN LANGUAGE PROCESSING IN PYTHON

  4. Opening an a u dio file in P y thon A u dio � le sa v ed as 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 IN PYTHON

  5. Working w ith a u dio is different Ha v e to con v ert the a u dio to something u sef u l Small sample of a u dio = large amo u nt of information SPOKEN LANGUAGE PROCESSING IN PYTHON

  6. Let ' s practice ! SP OK E N L AN G U AG E P R OC E SSIN G IN P YTH ON

  7. Con v erting so u nd w a v e b y tes to integers SP OK E N L AN G U AG E P R OC E SSIN G IN P YTH ON Daniel Bo u rke Machine Learning Engineer / Yo u T u be Creator

  8. Con v erting b y tes to integers Can ' t u se b y tes Con v ert b y tes to integers u sing n u mp y import numpy as np # Convert soundwave_gm from bytes to integers signal_gm = np.frombuffer(soundwave_gm, dtype='int16') # Show the first 10 items signal_gm[:10] array([ -3, -5, -8, -8, -9, -13, -8, -10, -9, -11], dtype=int16) SPOKEN LANGUAGE PROCESSING IN PYTHON

  9. Finding the frame rate Freq u enc y ( H z) = length of w a v e object arra y/ d u ration of a u dio � le ( seconds ) # Get the frame rate framerate_gm = good_morning.getframerate() # Show the frame rate framerate_gm 48,000 D u ration of a u dio � le ( seconds ) = length of w a v e object arra y/ freq u enc y ( H z) SPOKEN LANGUAGE PROCESSING IN PYTHON

  10. Finding so u nd w a v e timestamps # Return evenly spaced values between start and stop np.linspace(start=1, stop=10, num=10) array([ 1., 2., 3., 4., 5., 6., 7., 8., 9., 10.]) # Get the timestamps of the good morning sound wave time_gm = np.linspace(start=0, stop=len(soundwave_gm)/framerate_gm, num=len(soundwave_gm)) SPOKEN LANGUAGE PROCESSING IN PYTHON

  11. Finding so u nd w a v e timestamps # View first 10 time stamps of good morning sound wave time_gm[:10] array([0.00000000e+00, 2.08334167e-05, 4.16668333e-05, 6.25002500e-05, 8.33336667e-05, 1.04167083e-04, 1.25000500e-04, 1.45833917e-04, 1.66667333e-04, 1.87500750e-04]) SPOKEN LANGUAGE PROCESSING IN PYTHON

  12. Let ' s practice ! SP OK E N L AN G U AG E P R OC E SSIN G IN P YTH ON

  13. Vis u ali z ing so u nd w a v es SP OK E N L AN G U AG E P R OC E SSIN G IN P YTH ON Daniel Bo u rke Machine Learning Engineer / Yo u T u be Creator

  14. Adding another so u nd w a v e Ne w a u dio � le : good_afternoon.wav Both are 48 kH z Same data transformations to all a u dio � les SPOKEN LANGUAGE PROCESSING IN PYTHON

  15. Setting u p a plot import matplotlib.pyplot as plt # Initialize figure and setup title plt.title("Good Afternoon vs. Good Morning") # x and y axis labels plt.xlabel("Time (seconds)") plt.ylabel("Amplitude") # Add good morning and good afternoon values plt.plot(time_ga, soundwave_ga, label ="Good Afternoon") plt.plot(time_gm, soundwave_gm, label="Good Morning", alpha=0.5) # Create a legend and show our plot plt.legend() plt.show() SPOKEN LANGUAGE PROCESSING IN PYTHON

  16. SPOKEN LANGUAGE PROCESSING IN PYTHON

  17. Time to v is u ali z e ! SP OK E N L AN G U AG E P R OC E SSIN G IN P YTH ON

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend