Skip to main content
Solved

Is it possible to add transfomer with PC sound notification? Eg. If unexpected path event was detected or a scound notification to the data inspector new window opening?


Is it possible to add transfomer with PC sound notification? Eg. If unexpected path event was detected or a scound notification to the data inspector new window opening?

Best answer by david_r

If you're on Windows, you can use two lines of code in a PythonCaller, e.g.

import winsound
winsound.MessageBeep()

This will trigger the sound file that is associated with the "Default Beep" event in the Windows sound settings:

imageMore info here: https://docs.python.org/3/library/winsound.html

View original
Did this help you find an answer to your question?

7 replies

nielsgerrits
VIP

You can set sounds under Tools, Options, Appearence, Advanced Options, Configure Sound Events...

If you need more specific / custom stuff you can use a SystemCaller to start anything you want :)


david_r
Evangelist
  • Best Answer
  • March 27, 2023

If you're on Windows, you can use two lines of code in a PythonCaller, e.g.

import winsound
winsound.MessageBeep()

This will trigger the sound file that is associated with the "Default Beep" event in the Windows sound settings:

imageMore info here: https://docs.python.org/3/library/winsound.html


nielsgerrits
VIP
david_r wrote:

If you're on Windows, you can use two lines of code in a PythonCaller, e.g.

import winsound
winsound.MessageBeep()

This will trigger the sound file that is associated with the "Default Beep" event in the Windows sound settings:

imageMore info here: https://docs.python.org/3/library/winsound.html

import winsound
 
class FeatureProcessor(object):
 
    def input(self, feature):
        frequency = 2500 # Set Frequency To 2500 Hertz
        duration = 100 # Set Duration To 1000 ms == 1 second
        winsound.Beep(frequency, duration)
        self.pyoutput(feature)

Working sample for the not Python experts like me:)


jkr_wrk
Influencer
Forum|alt.badge.img+28
  • March 27, 2023
nielsgerrits wrote:
import winsound
 
class FeatureProcessor(object):
 
    def input(self, feature):
        frequency = 2500 # Set Frequency To 2500 Hertz
        duration = 100 # Set Duration To 1000 ms == 1 second
        winsound.Beep(frequency, duration)
        self.pyoutput(feature)

Working sample for the not Python experts like me:)

Let's delete the default comments and keep the default functions.

 

This script plays a different sound (length) when groups exit the transformer, so it sounds like morse.

 

import fme
import fmeobjects
import winsound
 
class FeatureProcessor(object):
    freq = 2000
    duration = 100
    groupfreq = 2000
    groupduration = 300
 
    def __init__(self):
        pass
 
    def input(self, feature):
        winsound.Beep(self.freq,self.duration)
        self.pyoutput(feature)
 
    def close(self):
        pass
 
    def process_group(self):
        winsound.Beep(self.groupfreq,self.groupduration)

 

 

 

 


jkr_wrk
Influencer
Forum|alt.badge.img+28
  • March 27, 2023
nielsgerrits wrote:
import winsound
 
class FeatureProcessor(object):
 
    def input(self, feature):
        frequency = 2500 # Set Frequency To 2500 Hertz
        duration = 100 # Set Duration To 1000 ms == 1 second
        winsound.Beep(frequency, duration)
        self.pyoutput(feature)

Working sample for the not Python experts like me:)

And the most minimalist version that works:

import winsound
winsound.MessageBeep()
def FeatureProcessor(feature):
    pass

Because you have to set a Class or Function to Process Features. And this Class or Function has to accept the 'feature' object.

 

But be aware that this only plays sounds if you have your system sounds enabled.

Else the Beep(2000,100) and not the MessageBeep() would be the way to go.

 

 


  • Author
  • March 27, 2023

Thank you.


david_r
Evangelist
  • March 27, 2023
nielsgerrits wrote:
import winsound
 
class FeatureProcessor(object):
 
    def input(self, feature):
        frequency = 2500 # Set Frequency To 2500 Hertz
        duration = 100 # Set Duration To 1000 ms == 1 second
        winsound.Beep(frequency, duration)
        self.pyoutput(feature)

Working sample for the not Python experts like me:)

Lol, I think you should create an idea for a MIDI file reader ;-)


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings