audio - How To Read a Song in python letter by letter while playing the sound file of that song -


i'm trying make python read song text file while playing song @ same time. way reads song sort of how song portal(still alive) being played.

its kinda of tricky think, need python print out song each letter @ time while keeping pace actual song.

any appreciated.

regards!

edit

import urllib.request # example url   url = "http://ntl.matrix.com.br/pfilho/oldies_list/top/lyrics/black_or_white.txt" # open url: returns file-like object  lyrics = urllib.request.urlopen(url) # read raw data, return "bytes object"  text = lyrics.read() # print raw data  print(text) # print decoded data:  print(text.decode('utf-8')) 

edit:

ok , think may broad answer, here's want do: able print each character reading textfile , able set speed of reading/printing it.

here's basic code assumes have lot of information before hand.

import sys time import sleep # python 2 import #from itertools import izip zip # delay in seconds wait before printing each *character* of song lyrics time_delays = [0.1, 0.1, 0.1, 0.5, 0.2, 0.1, 0.1] song_lyrics = "thesong"  print "let's sing song..." song_char, char_delay in zip(song_lyrics, time_delays):     sleep(char_delay)     sys.stdout.write(song_char)     sys.stdout.flush() 

hope helps. reason use sys.stdout instead of print because easier control , need flush buffer otherwise screen update when buffer full.


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -