import os
import pyaudio
import wave
import sys

def voice_numberMap(value):
    valueScaled = float(value - 0) / float(100)
    return valueScaled * 31



while True:
    os.system("amixer cset numid=8,iface=MIXER,name='LINEOUT volume'voice_numberMap(25)")
    CHUNK = 1024
    wf = wave.open(r"/root/preset/audio/funky_stars_quazar.wav", 'rb')#(sys.argv[1], 'rb'
    p = pyaudio.PyAudio()

    stream = p.open(format=p.get_format_from_width(wf.getsampwidth()),channels=wf.getnchannels(),rate=wf.getframerate(),output=True)

    data = wf.readframes(CHUNK)
    while len(data) > 0:
        stream.write(data)
        data = wf.readframes(CHUNK)

    stream.stop_stream()
    stream.close()

    p.terminate()
