Skip to content

Commit

Permalink
Updated to 1.1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DonFlymoor committed Sep 18, 2020
1 parent 1e1ffc3 commit 124fbbb
Show file tree
Hide file tree
Showing 7 changed files with 76 additions and 28 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ Assuming all went well, you should see a file named test.mp3. Play it with your

### Use a sound Effect

Navigate to your home directory and create a folder named `.voxtalkz`.
Navigate to your home directory (On windows that's C:/Users/Username) and create a folder named `.voxtalkz`.

Navigate into that folder and create a new folder named `soundEffects`.

Download a .mp3 sound effect and place it in the `.voxtalkz/soundEffects/` folder, for this tutorial we will assume the file is called `footsteps.mp3`.
Download a .mp3 or .wav sound effect (other filetypes will be made available upon request, or as I need them) and place it in the `.voxtalkz/soundEffects/` folder, for this tutorial we will assume the file is called `footsteps.mp3`.

Write a short script and save it as `test2.script`.

Expand Down Expand Up @@ -157,7 +157,7 @@ This project is licensed under the GNUv3 License - see the [LICENSE.md](LICENSE)
Script file must be written in this manner:

#The first time a unknown name is called, instead of making the person talk, the name will be assigned to a person.
Susan:normal_woman
Susan:american_woman
#Then the person will "talk"
Susan:Hello, world!
#Comments are allowed!
Expand All @@ -172,10 +172,10 @@ This project is licensed under the GNUv3 License - see the [LICENSE.md](LICENSE)
@FADE | Fade to nothing
@FADE_IN | Fade in from silent
@OVERLAY | Overlays the sound onto what has already been recorded. Use @OVERLAY=VAR1 to START the overlay at the begining of where you assigned @VAR=1
@REPEAT= | Repeat audio segment however many times you specify. e.g. (normal_woman:Hello, world!@REPEAT=10) would produce Someone saying "Hello, world!" ten times
@REPEAT= | Repeat audio segment however many times you specify. e.g. (american_woman:Hello, world!@REPEAT=10) would produce Someone saying "Hello, world!" ten times
@VAR= | Assign a number to a temporary table. Only used with @OVERLAY
@VOLUME= | Set volume change in decibels. A negitive number will reduce the volume
@PITCH= | Set pitch change. e.g. "normal_woman:Hello, world!@PITCH=0.3" would make the person sound like a little girl, while "normal_woman:Hello, world!@PITCH=-0.3" would sound like an old woman
@PITCH= | Set pitch change. e.g. "american_woman:Hello, world!@PITCH=0.3" would make the person sound like a little girl, while "american_woman:Hello, world!@PITCH=-0.3" would sound like an old woman

List of all actors:
indian_man | Clearly speaks
Expand All @@ -202,9 +202,9 @@ This project is licensed under the GNUv3 License - see the [LICENSE.md](LICENSE)
bored_teen
happy_girl
boss_lady
youong_grandma
young_grandma
spoiled_girl
normal_woman
american_woman
Sound effects must be in the .mp3 format and placed in /home/user/.voxtalk/soundEffects
To use footsteps.mp3: put '*footsteps' in your script
Sound effects must be in the .mp3 or .wav format and placed in /home/user/.voxtalk/soundEffects
To use footsteps.mp3 as a sound effect: put '*footsteps' in your script
15 changes: 15 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
9/11/2020
1.1.2
- Bumped version to 1.1.2
- Added support for wav sound effects

9/11/2020
- Added the possiblity for not using a collin in your script

9/14/2020
1.1.3
- Bumped version to 1.1.3
- Made the option to retry a sound effect
- Changed yuoung_grandma to young_grandma
- REPEAT modifier defaults to 2
- Added suport for ogg sound effects
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
EMAIL = '[email protected]'
AUTHOR = 'Don Flymoor'
REQUIRES_PYTHON = '>=3.6.0'
VERSION = '1.1.2'
VERSION = '1.1.3'

# What packages are required for this module to be executed?
REQUIRED = [
Expand Down
2 changes: 1 addition & 1 deletion voxtalkz/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@

from .voxtalkz import *

__version__ = '1.1.2'
__version__ = '1.1.3'
Binary file modified voxtalkz/__pycache__/__init__.cpython-37.pyc
Binary file not shown.
Binary file modified voxtalkz/__pycache__/voxtalkz.cpython-37.pyc
Binary file not shown.
67 changes: 50 additions & 17 deletions voxtalkz/voxtalkz.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
import sys, os.path as path
import io, time
from pydub import AudioSegment
import __builtin__
import datetime

file = 'null'

def print(args):
with open(file,'w') as file:
file.write(args)
return __builtin__.print(*args, **kwargs)

class voxTalkz():
'''
Expand All @@ -26,6 +35,7 @@ class voxTalkz():
'''

def __init__(self, file, name, debug=False, timeme=False):
global file
self.homedir = path.expanduser('~')
self.name = name
self.debug = debug
Expand Down Expand Up @@ -63,9 +73,9 @@ def __init__(self, file, name, debug=False, timeme=False):
"bored_teen":"te",
"happy_girl":"th",
"boss_lady":"tl",
"youong_grandma":"vi",
"young_grandma":"vi",
"spoiled_girl":"zh-cn",
"normal_woman":"en"}
"american_woman":"en"}
def ToSound(self):
# parse the file
parsed = self.Parse(self.file)
Expand Down Expand Up @@ -116,11 +126,17 @@ def Parse(self,file,FILE=False):
List[i] = '\n'
continue
List[i] = List[i].replace('\n','')
# Chech if it is a sound effect
# Check if it is a sound effect
if '*' in List[i]:
List[i]=['SOUND',(List[i].replace('*','')).replace('\n','')]
else:
elif ':' in List[i]:
List[i] = (List[i].replace('\n','')).split(':')
# If the user forgot, then add a collin
else:
print(f'Error on line {i}! \n {List[i]} \nNo collin or astrix. Assuming collin, Attempting to fix')
assumedName = (List[i].replace('\n','')).split(' ')[0]
List[i] = [assumedName, List[i].replace(assumedName, '')]

while '\n' in List:
List.remove('\n')
# Return our list
Expand All @@ -129,9 +145,9 @@ def Parse(self,file,FILE=False):
return List

def help(self):
print("Usage: python3 -m voxtalkz [input file, output file] \n\nConverts play-like script to a .mp3 file \nScript file must be written in this manner: \n\n#The first time a unknown name is called, instead of making the person talk, the name will be assigned to a person. \nSusan:normal_woman\n#Then the person will \"talk\"\nSusan:Hello, world!\n#Comments are allowed!\n*soundeffect \n\nEffects can be applied by adding an @ symbal the the effect name, like so:\nperson1:hello, world!@VOLUME=8\nA second effect can be applied by using the pipe(\"|\") like so:\nperson1:Hello, World!@FADE|VOLUME=8\n")
print("Usage: python3 -m voxtalkz [input file, output file] \n\nConverts play-like script to a .mp3 file \nScript file must be written in this manner: \n\n#The first time a unknown name is called, instead of making the person talk, the name will be assigned to a person. \nSusan:american_woman\n#Then the person will \"talk\"\nSusan:Hello, world!\n#Comments are allowed!\n*soundeffect \n\nEffects can be applied by adding an @ symbal the the effect name, like so:\nperson1:hello, world!@VOLUME=8\nA second effect can be applied by using the pipe(\"|\") like so:\nperson1:Hello, World!@FADE|VOLUME=8\n")
print("List of all effects:")
list = ["@FADE | Fade to nothing","@FADE_IN | Fade in from silent","@OVERLAY | Overlays the sound onto what has already been recorded. Use @OVERLAY=VAR1 to START the overlay at the begining of where you assigned @VAR=1","@REPEAT= | Repeat audio segment however many times you specify. e.g. (normal_woman:Hello, world!@REPEAT=10) would produce someone saying \"Hello, world!\" ten times","@VAR= | Assign a number to a temporary table. Only used with @OVERLAY","@VOLUME= | Set volume change in decibels. A negitive number will reduce the volume","@PITCH= | Set pitch change. e.g. \"normal_woman:Hello, world!@PITCH=0.3\" would make the person sound like a little girl, while \"normal_woman:Hello, world!@PITCH=-0.3\" would sound like an old woman"]
list = ["@FADE | Fade to nothing","@FADE_IN | Fade in from silent","@OVERLAY | Overlays the sound onto what has already been recorded. Use @OVERLAY=VAR1 to START the overlay at the begining of where you assigned @VAR=1","@REPEAT= | Repeat audio segment however many times you specify. e.g. (american_woman:Hello, world!@REPEAT=10) would produce someone saying \"Hello, world!\" ten times","@VAR= | Assign a number to a temporary table. Only used with @OVERLAY","@VOLUME= | Set volume change in decibels. A negitive number will reduce the volume","@PITCH= | Set pitch change. e.g. \"american_woman:Hello, world!@PITCH=0.3\" would make the person sound like a little girl, while \"american_woman:Hello, world!@PITCH=-0.3\" would sound like an old woman"]
for string in list:
print(" "+string)
print("\nList of all actors:")
Expand Down Expand Up @@ -163,9 +179,9 @@ def help(self):
"bored_teen":"te",
"happy_girl":"th",
"boss_lady":"tl",
"youong_grandma":"vi",
"young_grandma":"vi",
"spoiled_girl":"zh-cn",
"normal_woman":"en"}
"american_woman":"en"}
for string in actors:
print(" "+string)
print("\nSound effects must be in the .mp3 format and placed in /home/user/.voxtalk/soundEffects\n To use footsteps.mp3: put *footsteps in your script")
Expand All @@ -191,13 +207,28 @@ def ListToSound(self, Lists):
if List[0] == 'SOUND':
if self.debug:
print('Makeing %s...'%List[1])
try:
audio_segment = AudioSegment.from_mp3(self.homedir+'/.voxTalkz/soundEffects/'+List[1]+'.mp3')
if self.debug:
print("Done!\n")
except:
print('\n !!! Could not open %s'%(self.homedir+'/.voxTalkz/soundEffects/'+List[1]+'.mp3 !!!, opening a random file instead'))
continue
while True:
try:
try:
audio_segment = AudioSegment.from_mp3(self.homedir+'/.voxTalkz/soundEffects/'+List[1]+'.mp3')
except:
audio_segment = AudioSegment.from_wav(self.homedir+'/.voxTalkz/soundEffects/'+List[1]+'.wav')
except:
audio_segment = AudioSegment.from_ogg(self.homedir+'/.voxTalkz/soundEffects/'+List[1]+'.ogg')
if self.debug:
print("Done!\n")
break
except:
contd = input('\n !!! Could not open %s'%(self.homedir+'/.voxTalkz/soundEffects/'+List[1]+'.mp3 (or .wav, or ogg) !!! Type continue to skip the sound effect, retry to retry after you\'ve fixed the problem, or exit to quit.'))
if contd == 'continue':
break
elif contd == 'retry':
pass
elif contd == 'exit':
return False
else:
print(f'{contd} is not an applicable answer. Trying again.')
pass
# Open sound to a variable

elif List[0] in self.Crew:
Expand Down Expand Up @@ -256,8 +287,8 @@ def ListToSound(self, Lists):
if self.debug:
print('%s is now a %s\n'%(List[0],List[1]))
except:
print("%s is NOT a type of person! Using normal_woman..."%List[1])
self.Crew.__setitem__(List[0], self.Crew['normal_woman'])
print("%s is NOT a type of person! Using american_woman..."%List[1])
self.Crew.__setitem__(List[0], self.Crew['american_woman'])

# Apply effects
if effects != False:
Expand Down Expand Up @@ -306,6 +337,8 @@ def ListToSound(self, Lists):
pass

elif parsed[0] == "REPEAT":
if not parsed[1]:
parsed[1] = 2
audio_segment *= int(parsed[1])

elif parsed[0] == "FADE":
Expand Down

0 comments on commit 124fbbb

Please sign in to comment.