Git Product home page Git Product logo

audiogen's People

Contributors

aroman avatar casebeer avatar jhobbs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

audiogen's Issues

Pitch is doubled after saving to wave

When I run the following script using audiogen, the output wave file has a pitch that is double the specified frequency, and the silence duration is only .5 second instead of the expected 1 second. I've had a hard time tracking down the culprit for this... any ideas?

import audiogen
import itertools

def silence_tone(silence):
    """
    parameter is length of time in seconds
    """
    return itertools.chain( audiogen.silence(silence), audiogen.tone(440), )

def make_wave(destination):

    output = audiogen.util.mixer(
        # first parameter is all of the source generators
        ( silence_tone(0), silence_tone(1), ),
        #next is a list of parameters for each channel
        #to specify levels for each of the previous source generators:
        (
            (audiogen.util.constant(1), audiogen.util.constant(0)),
            (audiogen.util.constant(0), audiogen.util.constant(1)),
            )
        )

    with open(destination, "wb") as f:
        #crop will set the maximum length of the file (so not infinite)
        audiogen.sampler.write_wav(f, audiogen.util.crop(output, 2.0))


destination = "output.wav"
make_wave(destination)

SyntaxError: invalid syntax

Running Python 3.6.9

The following script:

#!/usr/bin/env python3
import audiogen
audiogen.sampler.play(audiogen.tone(440))

Generates the error:

jeff@machine:~$ ./test_audio.py 
Traceback (most recent call last):
  File "./test_audio.py", line 3, in <module>
    import audiogen
  File "/home/jeff/.local/lib/python3.6/site-packages/audiogen/__init__.py", line 2, in <module>
    from .sampler import frame_rate
  File "/home/jeff/.local/lib/python3.6/site-packages/audiogen/sampler.py", line 64
    except IOError, e:
                  ^
SyntaxError: invalid syntax

except IOError, e:

Python3 compatibility

Hello,
It would be nice to make audiogen compatible with python 3.x
installing it with pip generates syntax errors :

  Running setup.py install for audiogen
      File "/usr/local/lib/python3.4/dist-packages/audiogen/util.py", line 28
        print "cropping %d channel(s) to %d samples each" % (len(gens), seconds * sampler.FRAME_RATE)
                                                        ^
    SyntaxError: invalid syntax

      File "/usr/local/lib/python3.4/dist-packages/audiogen/sampler.py", line 64
        except IOError, e:
                      ^
    SyntaxError: invalid syntax

generate 1khz tone at 19khz using BandPass Filter at 192khz sample rate

Hi I would like to generate 1 khz sine wave which I can do fine with this code

import math        #import needed modules
import pyaudio     #sudo apt-get install python-pyaudio


#List I/O Audio ports to use
#Input Device id  0  -  Microsoft Sound Mapper - Input
#Input Device id  1  -  Line 1 (Virtual Audio Cable)
#Input Device id  2  -  Line 4 (Virtual Audio Cable)
#Input Device id  3  -  Line In (Realtek High Definitio
#Input Device id  4  -  Line 2 (Virtual Audio Cable)
#Input Device id  5  -  Microphone (Realtek High Defini
#Input Device id  6  -  Line 3 (Virtual Audio Cable)
#Output Device id  7  -  Microsoft Sound Mapper - Output
#Output Device id  8  -  Speakers (Realtek High Definiti
#Output Device id  9  -  Line 1 (Virtual Audio Cable)
#Output Device id  10  -  Line 3 (Virtual Audio Cable)
#Output Device id  11  -  Line 2 (Virtual Audio Cable)
#Output Device id  12  -  Line 4 (Virtual Audio Cable)


PyAudio = pyaudio.PyAudio     #initialize pyaudio

#See https://en.wikipedia.org/wiki/Bit_rate#Audio
BITRATE = 192000     #number of frames per second/frameset.      

FREQUENCY = 1000     #Hz, waves per second, 261.63=C4-note.
LENGTH = 10     #seconds to play sound

if FREQUENCY > BITRATE:
    BITRATE = FREQUENCY+100

NUMBEROFFRAMES = int(BITRATE * LENGTH)
RESTFRAMES = NUMBEROFFRAMES % BITRATE
WAVEDATA = ''    

#generating wawes
for x in xrange(NUMBEROFFRAMES):
 WAVEDATA = WAVEDATA+chr(int(math.sin(x/((BITRATE/FREQUENCY)/math.pi))*127+128))    

for x in xrange(RESTFRAMES): 
 WAVEDATA = WAVEDATA+chr(128)

p = PyAudio()

#Open Device for streaming
stream = p.open(format = p.get_format_from_width(1), 
                channels = 1, 
                rate = BITRATE, 
                output = True,
				output_device_index=9)

stream.write(WAVEDATA)
stream.stop_stream()
stream.close()
p.terminate()

the problem is that audio is plattered all over 192khz
audiogen

what I would like to do is move this to 19khz and cut all the junk out of the signal so it would look more like this:
audiogen2

I thought I could acomplish this with audiogen and then play generated samples using pyaudio (since you added bandpass filter) but I don't realy know how would I do this

Thanks for Anwsering and Best Regards

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.