<commit_before>
from kivy.logger import Logger
from mpf.core.config_player import ConfigPlayer


class SoundPlayer(ConfigPlayer):
    config_file_section = 'sound_player'

    def additional_processing(self, config):
        return config

    def play(self, settings, mode=None, **kwargs):
        try:
            if not mode.active:
                return
        except AttributeError:
            pass

        for s in settings:  # settings is a list of one or more sound configs

            # Retrieve sound asset by name
            sound_name = s.pop('sound')
            try:
                sound = self.machine.sounds[sound_name]
            except KeyError:
                Logger.warning("SoundPlayer: The specified sound does not exist ('{}') - "
                               "sound could not be played.".format(sound_name))
                return

            # Get track by name. If track was not provided, use the default track name from the sound.
            if s['track'] and s['track'] in self.mc.sound_system.tracks.keys():
                track = self.machine.sound_system.tracks[s['track']]
            else:
                track = sound.track

            track.play_sound(sound=sound, **s)
<commit_msg>Fixed bug in SoundPlayer<commit_after>
from kivy.logger import Logger
from mpf.core.config_player import ConfigPlayer


class SoundPlayer(ConfigPlayer):
    config_file_section = 'sound_player'

    def additional_processing(self, config):
        return config

    def play(self, settings, mode=None, **kwargs):
        try:
            if not mode.active:
                return
        except AttributeError:
            pass

        for s in settings:  # settings is a list of one or more sound configs

            # Retrieve sound asset by name
            sound_name = s['sound']
            try:
                sound = self.machine.sounds[sound_name]
            except KeyError:
                Logger.warning("SoundPlayer: The specified sound does not exist ('{}') - "
                               "sound could not be played.".format(sound_name))
                return

            config = s.copy()
            del config['sound']

            # Get track by name. If track was not provided, use the default track name from the sound.
            if config['track'] and config['track'] in self.mc.sound_system.tracks.keys():
                track = self.machine.sound_system.tracks[config['track']]
            else:
                track = sound.track

            track.play_sound(sound=sound, **config)

{'fraction_non_alphanumeric': 0.08333333333333333, 'fraction_numerical': 0.0, 'mean_word_length': 1.8411111111111111, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3195422', 'n_tokens_mistral': 663, 'n_tokens_neox': 631, 'n_words': 207}