Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

audio streaming python

def generate_sample(self, ob, preview):
    print("* Generating sample...")
    tone_out = array(ob, dtype=int16)

    if preview:
        print("* Previewing audio file...")

        bytestream = tone_out.tobytes()
        pya = pyaudio.PyAudio()
        stream = pya.open(format=pya.get_format_from_width(width=2), channels=1, rate=OUTPUT_SAMPLE_RATE, output=True)
        stream.write(bytestream)
        stream.stop_stream()
        stream.close()

        pya.terminate()
        print("* Preview completed!")
    else:
        write('sound.wav', SAMPLE_RATE, tone_out)
        print("* Wrote audio file!")
Comment

PREVIOUS NEXT
Code Example
Python :: how to create a variablein python 
Python :: how to make python open a program/desktop app 
Python :: django query multiple conditions 
Python :: camel case in python 
Python :: how to convert .ui file to .py 
Python :: how to print a list of strings in python 
Python :: delay print in python 
Python :: run in another thread decorator 
Python :: python cv2 imwrite 
Python :: list exclude list 
Python :: flask wtforms multiple select 
Python :: python plot two lines with different y axis 
Python :: numpy rolling average 
Python :: python insert list 
Python :: python global variable across files 
Python :: How to know size of Python list 
Python :: np array to list 
Python :: Discord python get member object by id 
Python :: Matplotlib rotated x tick labels 
Python :: str replace python regex 
Python :: pandas reset index 
Python :: Error: The file/path provided (flaskr) does not appear to exist. Please verify the path is correct. If app is not on PYTHONPATH, ensure the extension is .py 
Python :: strftime python multiple formats 
Python :: rounding values in pandas dataframe 
Python :: check if string contains python 
Python :: run python file from another python file 
Python :: python variable declare 
Python :: pandas isin 
Python :: tweepy aut code 
Python :: python nominatim get latitude from address 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =