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?

  • March 27, 2023
  • 7 replies
  • 46 views

mwoj
Contributor
Forum|alt.badge.img+1
  • Contributor
  • 4 replies
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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

7 replies

nielsgerrits
VIP
Forum|alt.badge.img+60
  • 2938 replies
  • March 27, 2023

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
Celebrity
  • 8392 replies
  • 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
Forum|alt.badge.img+60
  • 2938 replies
  • 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

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+35
  • 424 replies
  • March 27, 2023
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+35
  • 424 replies
  • March 27, 2023
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.

 

 


mwoj
Contributor
Forum|alt.badge.img+1
  • Author
  • Contributor
  • 4 replies
  • March 27, 2023

Thank you.


david_r
Celebrity
  • 8392 replies
  • March 27, 2023
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 ;-)