예제 #1
0
	def set_voice_param(self, type, value):
		if type == 'rate':
			self.voice_rate = int(value)
			if pyespeak:
				pyespeak.espeak_SetParameter(pyespeak.espeakRATE, self.voice_rate, 0)
			self.config.set('voice_rate', self.voice_rate)
		elif type == 'pitch':
			self.voice_pitch = int(value)
			if pyespeak:
				pyespeak.espeak_SetParameter(pyespeak.espeakPITCH, self.voice_pitch, 0)
			self.config.set('voice_pitch', self.voice_pitch)
예제 #2
0
	def __init__(self, *args, **kwargs):
		global pybass, pyespeak
		self.config_file_name = kwargs.pop('config_file_name', 'entrain.ini')
		self.config = config(file_name = self.config_file_name)
		self.time_delay = self.config.get_int('time_delay', 5)
		self.play_sound = self.config.get_bool('play_sound', True)
		self.sound_volume = self.config.get_float('sound_volume', 0.5)
		self.music_file = self.config.get('music_file', 'music//Ranger_Song.s3m')
		self.svg_directory = self.config.get('svg_dir', 'svg_data')
		if not os.path.isdir(self.svg_directory):
			self.svg_directory = ''
		self.bass_handle = None
		self.sound_playing = False
		self.menu_options = None
		if pybass:
			if pybass.BASS_Init(-1, 44100, 0, 0, 0):
				pybass.BASS_SetVolume(self.sound_volume)
				if os.path.isfile(self.music_file):
					self.bass_handle = pybass.BASS_MusicLoad(False, self.music_file, 0, 0, pybass.BASS_MUSIC_PRESCAN | pybass.BASS_SAMPLE_LOOP, 0)
					if self.play_sound:
						self.sound_play()
			else:
				pybass = None
		self.voice_rate = self.config.get_int('voice_rate', 150)
		self.voice_pitch = self.config.get_int('voice_pitch', 50)
		if pyespeak:
			if pyespeak.espeak_Initialize(pyespeak.AUDIO_OUTPUT_SYNCH_PLAYBACK, 0, '.', 0) == pyespeak.EE_INTERNAL_ERROR:
				pyespeak = None
			else:
				pyespeak.espeak_SetVoiceByName('default')
				pyespeak.espeak_SetParameter(pyespeak.espeakRATE, self.voice_rate, 0)
				pyespeak.espeak_SetParameter(pyespeak.espeakPITCH, self.voice_pitch, 0)
		default_driver_type = EDT_SOFTWARE
		if 'win' in sys.platform:
			default_driver_type = EDT_DIRECT3D9
		elif 'linux' in sys.platform:
			default_driver_type = EDT_OPENGL
		self.device_parameters = SIrrlichtCreationParameters()
		self.device_parameters.DriverType = self.config.get_int('driver_type', default_driver_type)
		self.device_parameters.WindowSize = dimension2du(self.config.get_int('window_width', 640), self.config.get_int('window_height', 480))
		self.device_parameters.AntiAlias = self.config.get_int('anti_alias', 2)
		self.device_parameters.WithAlphaChannel = self.config.get_bool('with_alpha_channel', True)
		self.device = createDeviceEx(self.device_parameters)
		self.menu_driver_types = {}
		self.help_dialog = None
		self.good_results = 0
		self.bad_results = 0
		#~ self.button_repeat_voice = None
		self.voice_on = self.config.get_bool('voice_on', True)
		self.font_size = self.config.get_int('font_size', 32)
		self.font_file = self.replace_env_vars(self.config.get('font_file', '@SYSTEMROOT@/Fonts/arial.ttf'))
		self.gui_font_size = self.config.get_int('gui_font_size', 24)
		self.gui_font_file = self.replace_env_vars(self.config.get('gui_font_file', '@SYSTEMROOT@/Fonts/arial.ttf'))
		self.svg_image = None
예제 #3
0
 def set_voice_param(self, type, value):
     if type == 'rate':
         self.voice_rate = int(value)
         if pyespeak:
             pyespeak.espeak_SetParameter(pyespeak.espeakRATE,
                                          self.voice_rate, 0)
         self.config.set('voice_rate', self.voice_rate)
     elif type == 'pitch':
         self.voice_pitch = int(value)
         if pyespeak:
             pyespeak.espeak_SetParameter(pyespeak.espeakPITCH,
                                          self.voice_pitch, 0)
         self.config.set('voice_pitch', self.voice_pitch)
예제 #4
0
 def __init__(self, *args, **kwargs):
     global pybass, pyespeak
     self.config_file_name = kwargs.pop('config_file_name', 'entrain.ini')
     self.config = config(file_name=self.config_file_name)
     self.time_delay = self.config.get_int('time_delay', 5)
     self.play_sound = self.config.get_bool('play_sound', True)
     self.sound_volume = self.config.get_float('sound_volume', 0.5)
     self.music_file = self.config.get('music_file',
                                       'music//Ranger_Song.s3m')
     self.svg_directory = self.config.get('svg_dir', 'svg_data')
     if not os.path.isdir(self.svg_directory):
         self.svg_directory = ''
     self.bass_handle = None
     self.sound_playing = False
     self.menu_options = None
     if pybass:
         if pybass.BASS_Init(-1, 44100, 0, 0, 0):
             pybass.BASS_SetVolume(self.sound_volume)
             if os.path.isfile(self.music_file):
                 self.bass_handle = pybass.BASS_MusicLoad(
                     False, self.music_file, 0, 0,
                     pybass.BASS_MUSIC_PRESCAN | pybass.BASS_SAMPLE_LOOP, 0)
                 if self.play_sound:
                     self.sound_play()
         else:
             pybass = None
     self.voice_rate = self.config.get_int('voice_rate', 150)
     self.voice_pitch = self.config.get_int('voice_pitch', 50)
     if pyespeak:
         if pyespeak.espeak_Initialize(pyespeak.AUDIO_OUTPUT_SYNCH_PLAYBACK,
                                       0, '.',
                                       0) == pyespeak.EE_INTERNAL_ERROR:
             pyespeak = None
         else:
             pyespeak.espeak_SetVoiceByName('default')
             pyespeak.espeak_SetParameter(pyespeak.espeakRATE,
                                          self.voice_rate, 0)
             pyespeak.espeak_SetParameter(pyespeak.espeakPITCH,
                                          self.voice_pitch, 0)
     default_driver_type = EDT_SOFTWARE
     if 'win' in sys.platform:
         default_driver_type = EDT_DIRECT3D9
     elif 'linux' in sys.platform:
         default_driver_type = EDT_OPENGL
     self.device_parameters = SIrrlichtCreationParameters()
     self.device_parameters.DriverType = self.config.get_int(
         'driver_type', default_driver_type)
     self.device_parameters.WindowSize = dimension2du(
         self.config.get_int('window_width', 640),
         self.config.get_int('window_height', 480))
     self.device_parameters.AntiAlias = self.config.get_int('anti_alias', 2)
     self.device_parameters.WithAlphaChannel = self.config.get_bool(
         'with_alpha_channel', True)
     self.device = createDeviceEx(self.device_parameters)
     self.menu_driver_types = {}
     self.help_dialog = None
     self.good_results = 0
     self.bad_results = 0
     #~ self.button_repeat_voice = None
     self.voice_on = self.config.get_bool('voice_on', True)
     self.font_size = self.config.get_int('font_size', 32)
     self.font_file = self.replace_env_vars(
         self.config.get('font_file', '@SYSTEMROOT@/Fonts/arial.ttf'))
     self.gui_font_size = self.config.get_int('gui_font_size', 24)
     self.gui_font_file = self.replace_env_vars(
         self.config.get('gui_font_file', '@SYSTEMROOT@/Fonts/arial.ttf'))
     self.svg_image = None