SlideShare a Scribd company logo
1 of 42
Download to read offline
RyAudio,
A Real-time Audio Spectrogram
with Application to Sound-Driven Games
in Python 3, Pyaudio, Pygame, and Pylab
Renyuan Lyu
呂仁園 1
May 18, 14:30, @R1
Preface
• Python helps me implement the real-time
spectrogram at the beginning of this year
(2014).
– After doing speech signal processing research for
a long time, I feel so excited to share that
excitement with friends.
– So I submit my program with a youtube demo to
this conference
2
• The followings are the scores and comments
given by the reviewers
• Reviewer #1: Score: 2
– No comments
• Reviewer #2: Score: 3
– real-time speech recognizer !!!
• Reviewer #3: Score: 3
– I'll admit being a bit selfish here. I have been planning
to work on audio analysing for a while. This looks like
a good start. :)
3
• Reviewer #4: Score: 0
– After reviewing his code carefully, I have to say
that his spectrogram analysis is not good for
speech processing. He took every 512 samples to
perform FFT to get spectrum under 16kHz
sampling rate. As far as I know, speech processing
will use so-called short-term frequency analysis,
which is different than this one. Well, it might be
an interesting topic for Python users as long as he
provides accurate and correct information about
DSP.
4
• Reviewer #5: Score: 2
– Sound recognition is different than speech
recognition, right?
• Reviewer #6: Score: 3
– I am too excited to give any comment. I would
even love to pay for his ticket just to listen to this
talk.
5
• By the way, Python 3 allows me to use my
native (most fluent) language to name the
variables, functions, and classes.
– That is even a more wonderful experience.
– I can have much more precise, more elegant
vocabulary to construct the program.
6
Overview
• Some Background on this talk
• Signal Processing, Speech
• Spectrum, Spectrogram
• Processing in Real Time
• An Awesome Example: Friture
• RyAudio
• A lighter example for realtime spectrogram
• Demo
• Some Comments on Programming in Native
Languages
• Using Chinese in Python 3
7
Signal Processing
• Signal Processing deals with operations on or
analysis of analog or digital signals,
representing time varying or spatially varying
physical quantities, like sound, image or video.
8http://upload.wikimedia.org/wikipedia/commons/4/46/Signal_processing_system.png
Speech
• Speech is a 1-dimentional signal
– a subclass of audio signal
• a representation of sound, typically as an electrical voltage
• with frequencies in the audio frequency range
– roughly 20 to 20,000 Hz (the limits of human hearing)
– the vocalized form of human language
• carrying linguistic information
– the frequency range within 8,000 Hz is enough
9
(Optical) Spectrum
• The word spectrum was first used
scientifically within the field of
optics
– to describe the rainbow of colors
in visible light
• when separated using a prism.
10
Audio/Speech Spectrum
• Spectrum can be also obtained from
audio/speech signal,
• where it represents the frequency distribution of the signal.
• Fast Fourier Transform (FFT)
• the core algorithm to get such a spectrum.
11
FFT
Spectrogram
• Speech as a time-varying signal
• short-time FFT is applied in the spectral analysis to form
a time-frequency spectrogram
– Typically the short-time frame is about 20 ms long.
• Free analysis tools for speech processing
• Audacity, Praat, ..etc
• Perfect for off-line, non-real-time processing
12
Processing in Real-time
• Real-time processing
– Acquiring, processing, responding simultaneously
• An example: Friture
– A Python application to visualize and analyze live
audio data in real-time.
– importing PyQt, PyQwt, PyAudio, Numpy, Scipy,
Cython, OpenGL, etc,..
– http://friture.org/
13
An Awesome Example: Friture
• I found this app in 2011.
• It was implemented in Python.
– this is one of the reasons why I was attracted into Python’s
world
14
• Comments on Friture:
– Cool, Splendid, Wonderful, Awesome!!
– But,
• Importing too many modules
– PyQt, PyQwt, PyAudio, Numpy, Scipy, Cython, OpenGL, etc,..
• Only in Python-2, Not yet in Python-3
– I have ONLY Python-3 environment installed
• Too complicated for me as a newbie to follow
– The Zen of Python
» Simple is better than complex.
» Complex is better than complicated.
15
A smaller dependent set
• A smaller dependent module set to implement a
real-time spectrogram
– PyAudio
• For acquiring speech
– http://people.csail.mit.edu/hubert/pyaudio/
– Pylab
• For DSP (FFT, etc)
– http://wiki.scipy.org/PyLab
– PyGame
• For displaying and GUI
– http://www.pygame.org/news.html
16
RyAudio
~ a class to deal with audio processing
17
Source Code can be found here
https://gist.github.com/renyuanL/
f9cb017a3a5b6c621b43
18
19
20
21
22
23
24
25
ryApp.py
~ an app of realtime spectrogram
26
27
28
29
30
31
32
• Source Code can be found here
– https://gist.github.com/renyuanL/f9cb017a3a5b6c621b43
33
Demo
• Demo in Youtube
• http://youtu.be/sFtKlLF88DU
34
Some Comments
on Programming in Native Languages
設計程式對非英語為母語的人來說,(特別是小孩)
允許其運用 其「母語」 來 「寫」,
比較有可能「登門入室」甚至「文思泉湧」,
因此能迅速產生「內容」。
等到「內容」大致底定,
為了與全球人士分享智慧的結晶,
需要將這種「母語」程式轉成「英語」程式,
以利全球範圍的流通。
以寫文章來做類比,
金庸 要用 中文 才寫得出 「神鵰俠侶」,
Mark Twain 要用 English 才寫得出 'Tom Sawyer'
一旦作品優秀、揚名了,自然有轉成其他語言與更多人
分享的需求
35
Python Code Translation
ryApp.py  ryApp_en.py
36
ryApp.py  ryApp_en.py
• https://gist.github.com/renyuanL/f9cb017a3a5b6c621b43
37
Examples of Chinese Programs
• http://apython.blogspot.tw/
• A set of Chinese Programs in Python 3
– https://gist.github.com/renyuanL/044b6bc6142dc
71086bc
– https://gist.github.com/renyuanL/a36f2a121c4d2
7753d8c
38
陰陽 Yinyang
• C:Python33Libturtledemoyinyang.py
39
Coding in your own native language
40
• If readability counts, then it will achieve
maximum when coding in your own native
language.
41
Thank you
for Listening
42

More Related Content

What's hot

Introductory Lecture to Audio Signal Processing
Introductory Lecture to Audio Signal ProcessingIntroductory Lecture to Audio Signal Processing
Introductory Lecture to Audio Signal ProcessingAngelo Salatino
 
Utp pds_l4_procesamiento de señales del habla con mat_lab
 Utp pds_l4_procesamiento de señales del habla con mat_lab Utp pds_l4_procesamiento de señales del habla con mat_lab
Utp pds_l4_procesamiento de señales del habla con mat_labjcbenitezp
 
Miniproject audioenhancement-100223094301-phpapp02
Miniproject audioenhancement-100223094301-phpapp02Miniproject audioenhancement-100223094301-phpapp02
Miniproject audioenhancement-100223094301-phpapp02mohankota
 
ESPnet-TTS: Unified, Reproducible, and Integratable Open Source End-to-End Te...
ESPnet-TTS: Unified, Reproducible, and Integratable Open Source End-to-End Te...ESPnet-TTS: Unified, Reproducible, and Integratable Open Source End-to-End Te...
ESPnet-TTS: Unified, Reproducible, and Integratable Open Source End-to-End Te...Tomoki Hayashi
 
Numba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPyNumba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPyTravis Oliphant
 
Speech Compression using LPC
Speech Compression using LPCSpeech Compression using LPC
Speech Compression using LPCDisha Modi
 
DSP_FOEHU - Lec 13 - Digital Signal Processing Applications I
DSP_FOEHU - Lec 13 - Digital Signal Processing Applications IDSP_FOEHU - Lec 13 - Digital Signal Processing Applications I
DSP_FOEHU - Lec 13 - Digital Signal Processing Applications IAmr E. Mohamed
 
Audio compression 1
Audio compression 1Audio compression 1
Audio compression 1Rajat Kumar
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Fwdays
 
Homomorphic speech processing
Homomorphic speech processingHomomorphic speech processing
Homomorphic speech processingsivakumar m
 
Sequence Learning with CTC technique
Sequence Learning with CTC techniqueSequence Learning with CTC technique
Sequence Learning with CTC techniqueChun Hao Wang
 
The Joy of SciPy
The Joy of SciPyThe Joy of SciPy
The Joy of SciPykammeyer
 
Audio and video compression
Audio and video compressionAudio and video compression
Audio and video compressionneeraj9217
 
Introduction to Python Pandas for Data Analytics
Introduction to Python Pandas for Data AnalyticsIntroduction to Python Pandas for Data Analytics
Introduction to Python Pandas for Data AnalyticsPhoenix
 
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLabIntroduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLabCloudxLab
 

What's hot (20)

Introductory Lecture to Audio Signal Processing
Introductory Lecture to Audio Signal ProcessingIntroductory Lecture to Audio Signal Processing
Introductory Lecture to Audio Signal Processing
 
Python Workshop
Python WorkshopPython Workshop
Python Workshop
 
Defying Nyquist in Analog to Digital Conversion
Defying Nyquist in Analog to Digital ConversionDefying Nyquist in Analog to Digital Conversion
Defying Nyquist in Analog to Digital Conversion
 
Utp pds_l4_procesamiento de señales del habla con mat_lab
 Utp pds_l4_procesamiento de señales del habla con mat_lab Utp pds_l4_procesamiento de señales del habla con mat_lab
Utp pds_l4_procesamiento de señales del habla con mat_lab
 
Miniproject audioenhancement-100223094301-phpapp02
Miniproject audioenhancement-100223094301-phpapp02Miniproject audioenhancement-100223094301-phpapp02
Miniproject audioenhancement-100223094301-phpapp02
 
Chennai python augustmeetup
Chennai python augustmeetupChennai python augustmeetup
Chennai python augustmeetup
 
ESPnet-TTS: Unified, Reproducible, and Integratable Open Source End-to-End Te...
ESPnet-TTS: Unified, Reproducible, and Integratable Open Source End-to-End Te...ESPnet-TTS: Unified, Reproducible, and Integratable Open Source End-to-End Te...
ESPnet-TTS: Unified, Reproducible, and Integratable Open Source End-to-End Te...
 
Numba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPyNumba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPy
 
Speech Compression using LPC
Speech Compression using LPCSpeech Compression using LPC
Speech Compression using LPC
 
H0814247
H0814247H0814247
H0814247
 
DSP_FOEHU - Lec 13 - Digital Signal Processing Applications I
DSP_FOEHU - Lec 13 - Digital Signal Processing Applications IDSP_FOEHU - Lec 13 - Digital Signal Processing Applications I
DSP_FOEHU - Lec 13 - Digital Signal Processing Applications I
 
Audio compression 1
Audio compression 1Audio compression 1
Audio compression 1
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"
 
Numba
NumbaNumba
Numba
 
Homomorphic speech processing
Homomorphic speech processingHomomorphic speech processing
Homomorphic speech processing
 
Sequence Learning with CTC technique
Sequence Learning with CTC techniqueSequence Learning with CTC technique
Sequence Learning with CTC technique
 
The Joy of SciPy
The Joy of SciPyThe Joy of SciPy
The Joy of SciPy
 
Audio and video compression
Audio and video compressionAudio and video compression
Audio and video compression
 
Introduction to Python Pandas for Data Analytics
Introduction to Python Pandas for Data AnalyticsIntroduction to Python Pandas for Data Analytics
Introduction to Python Pandas for Data Analytics
 
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLabIntroduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
Introduction To TensorFlow | Deep Learning Using TensorFlow | CloudxLab
 

Viewers also liked

(2013-11-29) [RuPy] AudioLazy Python DSP (Digital Signal Processing)
(2013-11-29) [RuPy] AudioLazy Python DSP (Digital Signal Processing)(2013-11-29) [RuPy] AudioLazy Python DSP (Digital Signal Processing)
(2013-11-29) [RuPy] AudioLazy Python DSP (Digital Signal Processing)Danilo J. S. Bellini
 
ICML Talk on deep learning for music recommendation
ICML Talk on deep learning for music recommendationICML Talk on deep learning for music recommendation
ICML Talk on deep learning for music recommendationAloïs Gruson
 
ISMIR 2016_Melody Extraction
ISMIR 2016_Melody ExtractionISMIR 2016_Melody Extraction
ISMIR 2016_Melody ExtractionSangeun Kum
 
Talwar_Rakshak_2016URD
Talwar_Rakshak_2016URDTalwar_Rakshak_2016URD
Talwar_Rakshak_2016URDRakshak Talwar
 
Audio chord recognition using deep neural networks
Audio chord recognition using deep neural networksAudio chord recognition using deep neural networks
Audio chord recognition using deep neural networksbzamecnik
 
Deep Learning Meetup #5
Deep Learning Meetup #5Deep Learning Meetup #5
Deep Learning Meetup #5Aloïs Gruson
 
Deep Learning for Speech Recognition - Vikrant Singh Tomar
Deep Learning for Speech Recognition - Vikrant Singh TomarDeep Learning for Speech Recognition - Vikrant Singh Tomar
Deep Learning for Speech Recognition - Vikrant Singh TomarWithTheBest
 
Big Data Day LA 2015 - Deep Learning Human Vocalized Animal Sounds by Sabri S...
Big Data Day LA 2015 - Deep Learning Human Vocalized Animal Sounds by Sabri S...Big Data Day LA 2015 - Deep Learning Human Vocalized Animal Sounds by Sabri S...
Big Data Day LA 2015 - Deep Learning Human Vocalized Animal Sounds by Sabri S...Data Con LA
 
Deep learning for music classification, 2016-05-24
Deep learning for music classification, 2016-05-24Deep learning for music classification, 2016-05-24
Deep learning for music classification, 2016-05-24Keunwoo Choi
 
Automatic Tagging using Deep Convolutional Neural Networks - ISMIR 2016
Automatic Tagging using Deep Convolutional Neural Networks - ISMIR 2016Automatic Tagging using Deep Convolutional Neural Networks - ISMIR 2016
Automatic Tagging using Deep Convolutional Neural Networks - ISMIR 2016Keunwoo Choi
 
GTC 2016 ディープラーニング最新情報
GTC 2016 ディープラーニング最新情報GTC 2016 ディープラーニング最新情報
GTC 2016 ディープラーニング最新情報NVIDIA Japan
 

Viewers also liked (11)

(2013-11-29) [RuPy] AudioLazy Python DSP (Digital Signal Processing)
(2013-11-29) [RuPy] AudioLazy Python DSP (Digital Signal Processing)(2013-11-29) [RuPy] AudioLazy Python DSP (Digital Signal Processing)
(2013-11-29) [RuPy] AudioLazy Python DSP (Digital Signal Processing)
 
ICML Talk on deep learning for music recommendation
ICML Talk on deep learning for music recommendationICML Talk on deep learning for music recommendation
ICML Talk on deep learning for music recommendation
 
ISMIR 2016_Melody Extraction
ISMIR 2016_Melody ExtractionISMIR 2016_Melody Extraction
ISMIR 2016_Melody Extraction
 
Talwar_Rakshak_2016URD
Talwar_Rakshak_2016URDTalwar_Rakshak_2016URD
Talwar_Rakshak_2016URD
 
Audio chord recognition using deep neural networks
Audio chord recognition using deep neural networksAudio chord recognition using deep neural networks
Audio chord recognition using deep neural networks
 
Deep Learning Meetup #5
Deep Learning Meetup #5Deep Learning Meetup #5
Deep Learning Meetup #5
 
Deep Learning for Speech Recognition - Vikrant Singh Tomar
Deep Learning for Speech Recognition - Vikrant Singh TomarDeep Learning for Speech Recognition - Vikrant Singh Tomar
Deep Learning for Speech Recognition - Vikrant Singh Tomar
 
Big Data Day LA 2015 - Deep Learning Human Vocalized Animal Sounds by Sabri S...
Big Data Day LA 2015 - Deep Learning Human Vocalized Animal Sounds by Sabri S...Big Data Day LA 2015 - Deep Learning Human Vocalized Animal Sounds by Sabri S...
Big Data Day LA 2015 - Deep Learning Human Vocalized Animal Sounds by Sabri S...
 
Deep learning for music classification, 2016-05-24
Deep learning for music classification, 2016-05-24Deep learning for music classification, 2016-05-24
Deep learning for music classification, 2016-05-24
 
Automatic Tagging using Deep Convolutional Neural Networks - ISMIR 2016
Automatic Tagging using Deep Convolutional Neural Networks - ISMIR 2016Automatic Tagging using Deep Convolutional Neural Networks - ISMIR 2016
Automatic Tagging using Deep Convolutional Neural Networks - ISMIR 2016
 
GTC 2016 ディープラーニング最新情報
GTC 2016 ディープラーニング最新情報GTC 2016 ディープラーニング最新情報
GTC 2016 ディープラーニング最新情報
 

Similar to Pycon apac 2014

Py conjp2019 renyuanlyu_3
Py conjp2019 renyuanlyu_3Py conjp2019 renyuanlyu_3
Py conjp2019 renyuanlyu_3Renyuan Lyu
 
Py conjp2019 renyuanlyu_3
Py conjp2019 renyuanlyu_3Py conjp2019 renyuanlyu_3
Py conjp2019 renyuanlyu_3Renyuan Lyu
 
How to start Python? - lesson 1
How to start Python? - lesson 1How to start Python? - lesson 1
How to start Python? - lesson 1Shohel Rana
 
FEC2017-Introduction-to-programming
FEC2017-Introduction-to-programmingFEC2017-Introduction-to-programming
FEC2017-Introduction-to-programmingHenrikki Tenkanen
 
An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()Blue Elephant Consulting
 
Introduction to Python – Learn Python Programming.pptx
Introduction to Python – Learn Python Programming.pptxIntroduction to Python – Learn Python Programming.pptx
Introduction to Python – Learn Python Programming.pptxHassanShah396906
 
Pi, Python, and Paintball??? Innovating with Affordable Tech!
Pi, Python, and Paintball??? Innovating with Affordable Tech!Pi, Python, and Paintball??? Innovating with Affordable Tech!
Pi, Python, and Paintball??? Innovating with Affordable Tech!Barry Tarlton
 
python classes in thane
python classes in thanepython classes in thane
python classes in thanefaizrashid1995
 
WebRTC, RED and Janus @ ClueCon21
WebRTC, RED and Janus @ ClueCon21WebRTC, RED and Janus @ ClueCon21
WebRTC, RED and Janus @ ClueCon21Lorenzo Miniero
 
Why should I learn python
Why should I learn pythonWhy should I learn python
Why should I learn pythongrinu
 
A Whirlwind Tour Of Python
A Whirlwind Tour Of PythonA Whirlwind Tour Of Python
A Whirlwind Tour Of PythonAsia Smith
 
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTED
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTEDPYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTED
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTEDBijay Acharya
 

Similar to Pycon apac 2014 (20)

Py conjp2019 renyuanlyu_3
Py conjp2019 renyuanlyu_3Py conjp2019 renyuanlyu_3
Py conjp2019 renyuanlyu_3
 
Py conjp2019 renyuanlyu_3
Py conjp2019 renyuanlyu_3Py conjp2019 renyuanlyu_3
Py conjp2019 renyuanlyu_3
 
Desktop assistant
Desktop assistant Desktop assistant
Desktop assistant
 
py4inf-01-intro.ppt
py4inf-01-intro.pptpy4inf-01-intro.ppt
py4inf-01-intro.ppt
 
How to start Python? - lesson 1
How to start Python? - lesson 1How to start Python? - lesson 1
How to start Python? - lesson 1
 
Python
PythonPython
Python
 
FEC2017-Introduction-to-programming
FEC2017-Introduction-to-programmingFEC2017-Introduction-to-programming
FEC2017-Introduction-to-programming
 
An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()An Introduction To Python - Python, Print()
An Introduction To Python - Python, Print()
 
Introduction to Python – Learn Python Programming.pptx
Introduction to Python – Learn Python Programming.pptxIntroduction to Python – Learn Python Programming.pptx
Introduction to Python – Learn Python Programming.pptx
 
Pi, Python, and Paintball??? Innovating with Affordable Tech!
Pi, Python, and Paintball??? Innovating with Affordable Tech!Pi, Python, and Paintball??? Innovating with Affordable Tech!
Pi, Python, and Paintball??? Innovating with Affordable Tech!
 
python classes in thane
python classes in thanepython classes in thane
python classes in thane
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
WebRTC, RED and Janus @ ClueCon21
WebRTC, RED and Janus @ ClueCon21WebRTC, RED and Janus @ ClueCon21
WebRTC, RED and Janus @ ClueCon21
 
Why should I learn python
Why should I learn pythonWhy should I learn python
Why should I learn python
 
UPNext
UPNextUPNext
UPNext
 
Python basics
Python basicsPython basics
Python basics
 
Everyday Python Idioms
Everyday Python IdiomsEveryday Python Idioms
Everyday Python Idioms
 
A Whirlwind Tour Of Python
A Whirlwind Tour Of PythonA Whirlwind Tour Of Python
A Whirlwind Tour Of Python
 
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTED
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTEDPYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTED
PYTHON PROGRAMMING FOR HACKERS. PART 1 – GETTING STARTED
 

More from Renyuan Lyu

Lightning talk01 docx
Lightning talk01 docxLightning talk01 docx
Lightning talk01 docxRenyuan Lyu
 
Lightning talk01
Lightning talk01Lightning talk01
Lightning talk01Renyuan Lyu
 
Pycon JP 2016 ---- Pitch Detection
Pycon JP 2016 ---- Pitch DetectionPycon JP 2016 ---- Pitch Detection
Pycon JP 2016 ---- Pitch DetectionRenyuan Lyu
 
pycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslatepycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslateRenyuan Lyu
 
pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__Renyuan Lyu
 
Ry pyconjp2015 turtle
Ry pyconjp2015 turtleRy pyconjp2015 turtle
Ry pyconjp2015 turtleRenyuan Lyu
 
Ry pyconjp2015 karaoke
Ry pyconjp2015 karaokeRy pyconjp2015 karaoke
Ry pyconjp2015 karaokeRenyuan Lyu
 
教青少年寫程式
教青少年寫程式教青少年寫程式
教青少年寫程式Renyuan Lyu
 

More from Renyuan Lyu (8)

Lightning talk01 docx
Lightning talk01 docxLightning talk01 docx
Lightning talk01 docx
 
Lightning talk01
Lightning talk01Lightning talk01
Lightning talk01
 
Pycon JP 2016 ---- Pitch Detection
Pycon JP 2016 ---- Pitch DetectionPycon JP 2016 ---- Pitch Detection
Pycon JP 2016 ---- Pitch Detection
 
pycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslatepycon jp 2016 ---- CguTranslate
pycon jp 2016 ---- CguTranslate
 
pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__
 
Ry pyconjp2015 turtle
Ry pyconjp2015 turtleRy pyconjp2015 turtle
Ry pyconjp2015 turtle
 
Ry pyconjp2015 karaoke
Ry pyconjp2015 karaokeRy pyconjp2015 karaoke
Ry pyconjp2015 karaoke
 
教青少年寫程式
教青少年寫程式教青少年寫程式
教青少年寫程式
 

Recently uploaded

Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)Dr SOUNDIRARAJ N
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...Chandu841456
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleAlluxio, Inc.
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...121011101441
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .Satyam Kumar
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catcherssdickerson1
 

Recently uploaded (20)

Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
UNIT III ANALOG ELECTRONICS (BASIC ELECTRONICS)
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...An experimental study in using natural admixture as an alternative for chemic...
An experimental study in using natural admixture as an alternative for chemic...
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
Correctly Loading Incremental Data at Scale
Correctly Loading Incremental Data at ScaleCorrectly Loading Incremental Data at Scale
Correctly Loading Incremental Data at Scale
 
Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...Instrumentation, measurement and control of bio process parameters ( Temperat...
Instrumentation, measurement and control of bio process parameters ( Temperat...
 
Churning of Butter, Factors affecting .
Churning of Butter, Factors affecting  .Churning of Butter, Factors affecting  .
Churning of Butter, Factors affecting .
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor CatchersTechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
TechTAC® CFD Report Summary: A Comparison of Two Types of Tubing Anchor Catchers
 

Pycon apac 2014

  • 1. RyAudio, A Real-time Audio Spectrogram with Application to Sound-Driven Games in Python 3, Pyaudio, Pygame, and Pylab Renyuan Lyu 呂仁園 1 May 18, 14:30, @R1
  • 2. Preface • Python helps me implement the real-time spectrogram at the beginning of this year (2014). – After doing speech signal processing research for a long time, I feel so excited to share that excitement with friends. – So I submit my program with a youtube demo to this conference 2
  • 3. • The followings are the scores and comments given by the reviewers • Reviewer #1: Score: 2 – No comments • Reviewer #2: Score: 3 – real-time speech recognizer !!! • Reviewer #3: Score: 3 – I'll admit being a bit selfish here. I have been planning to work on audio analysing for a while. This looks like a good start. :) 3
  • 4. • Reviewer #4: Score: 0 – After reviewing his code carefully, I have to say that his spectrogram analysis is not good for speech processing. He took every 512 samples to perform FFT to get spectrum under 16kHz sampling rate. As far as I know, speech processing will use so-called short-term frequency analysis, which is different than this one. Well, it might be an interesting topic for Python users as long as he provides accurate and correct information about DSP. 4
  • 5. • Reviewer #5: Score: 2 – Sound recognition is different than speech recognition, right? • Reviewer #6: Score: 3 – I am too excited to give any comment. I would even love to pay for his ticket just to listen to this talk. 5
  • 6. • By the way, Python 3 allows me to use my native (most fluent) language to name the variables, functions, and classes. – That is even a more wonderful experience. – I can have much more precise, more elegant vocabulary to construct the program. 6
  • 7. Overview • Some Background on this talk • Signal Processing, Speech • Spectrum, Spectrogram • Processing in Real Time • An Awesome Example: Friture • RyAudio • A lighter example for realtime spectrogram • Demo • Some Comments on Programming in Native Languages • Using Chinese in Python 3 7
  • 8. Signal Processing • Signal Processing deals with operations on or analysis of analog or digital signals, representing time varying or spatially varying physical quantities, like sound, image or video. 8http://upload.wikimedia.org/wikipedia/commons/4/46/Signal_processing_system.png
  • 9. Speech • Speech is a 1-dimentional signal – a subclass of audio signal • a representation of sound, typically as an electrical voltage • with frequencies in the audio frequency range – roughly 20 to 20,000 Hz (the limits of human hearing) – the vocalized form of human language • carrying linguistic information – the frequency range within 8,000 Hz is enough 9
  • 10. (Optical) Spectrum • The word spectrum was first used scientifically within the field of optics – to describe the rainbow of colors in visible light • when separated using a prism. 10
  • 11. Audio/Speech Spectrum • Spectrum can be also obtained from audio/speech signal, • where it represents the frequency distribution of the signal. • Fast Fourier Transform (FFT) • the core algorithm to get such a spectrum. 11 FFT
  • 12. Spectrogram • Speech as a time-varying signal • short-time FFT is applied in the spectral analysis to form a time-frequency spectrogram – Typically the short-time frame is about 20 ms long. • Free analysis tools for speech processing • Audacity, Praat, ..etc • Perfect for off-line, non-real-time processing 12
  • 13. Processing in Real-time • Real-time processing – Acquiring, processing, responding simultaneously • An example: Friture – A Python application to visualize and analyze live audio data in real-time. – importing PyQt, PyQwt, PyAudio, Numpy, Scipy, Cython, OpenGL, etc,.. – http://friture.org/ 13
  • 14. An Awesome Example: Friture • I found this app in 2011. • It was implemented in Python. – this is one of the reasons why I was attracted into Python’s world 14
  • 15. • Comments on Friture: – Cool, Splendid, Wonderful, Awesome!! – But, • Importing too many modules – PyQt, PyQwt, PyAudio, Numpy, Scipy, Cython, OpenGL, etc,.. • Only in Python-2, Not yet in Python-3 – I have ONLY Python-3 environment installed • Too complicated for me as a newbie to follow – The Zen of Python » Simple is better than complex. » Complex is better than complicated. 15
  • 16. A smaller dependent set • A smaller dependent module set to implement a real-time spectrogram – PyAudio • For acquiring speech – http://people.csail.mit.edu/hubert/pyaudio/ – Pylab • For DSP (FFT, etc) – http://wiki.scipy.org/PyLab – PyGame • For displaying and GUI – http://www.pygame.org/news.html 16
  • 17. RyAudio ~ a class to deal with audio processing 17 Source Code can be found here https://gist.github.com/renyuanL/ f9cb017a3a5b6c621b43
  • 18. 18
  • 19. 19
  • 20. 20
  • 21. 21
  • 22. 22
  • 23. 23
  • 24. 24
  • 25. 25
  • 26. ryApp.py ~ an app of realtime spectrogram 26
  • 27. 27
  • 28. 28
  • 29. 29
  • 30. 30
  • 31. 31
  • 32. 32
  • 33. • Source Code can be found here – https://gist.github.com/renyuanL/f9cb017a3a5b6c621b43 33
  • 34. Demo • Demo in Youtube • http://youtu.be/sFtKlLF88DU 34
  • 35. Some Comments on Programming in Native Languages 設計程式對非英語為母語的人來說,(特別是小孩) 允許其運用 其「母語」 來 「寫」, 比較有可能「登門入室」甚至「文思泉湧」, 因此能迅速產生「內容」。 等到「內容」大致底定, 為了與全球人士分享智慧的結晶, 需要將這種「母語」程式轉成「英語」程式, 以利全球範圍的流通。 以寫文章來做類比, 金庸 要用 中文 才寫得出 「神鵰俠侶」, Mark Twain 要用 English 才寫得出 'Tom Sawyer' 一旦作品優秀、揚名了,自然有轉成其他語言與更多人 分享的需求 35
  • 36. Python Code Translation ryApp.py  ryApp_en.py 36
  • 37. ryApp.py  ryApp_en.py • https://gist.github.com/renyuanL/f9cb017a3a5b6c621b43 37
  • 38. Examples of Chinese Programs • http://apython.blogspot.tw/ • A set of Chinese Programs in Python 3 – https://gist.github.com/renyuanL/044b6bc6142dc 71086bc – https://gist.github.com/renyuanL/a36f2a121c4d2 7753d8c 38
  • 40. Coding in your own native language 40
  • 41. • If readability counts, then it will achieve maximum when coding in your own native language. 41