ozdemirburak / morse-decoder Goto Github PK
View Code? Open in Web Editor NEWMorse code translator and decoder, which can also play audio.
Home Page: https://morsedecoder.com
License: MIT License
Morse code translator and decoder, which can also play audio.
Home Page: https://morsedecoder.com
License: MIT License
Thai alphabet characters are missing, someone who knows Thai can implement it.
You can add the Thai Alphabet after the Korean one.
'12': { // Thai Alphabet => https://th.wikipedia.org/wiki/รหัสมอร์ส
'ก': '110'
}
Currently, source code is outdated. It would be great if we turn it to ES6.
Hint: You may check online tools like Lebab.
const oscillator = offlineContext.createOscillator();
^
TypeError: Cannot read property 'createOscillator' of null
I can't resolve this error, something can help me?
Is there any way to detect when a morse audio has ended? What I want to do is to change the class of a button after the audio has ended. Thank you
This is a weird bug that I found recently. I have not had a chance to try it on a MacBook or an emulator, but I tried with both iOS 11 and iOS 12 in Safari Mobile and I still could not figure it out.
If you click to the Play button, not only you may not stop it from playing, but also you may not make it play more than once.
You can find an example and test it out on JSFiddle.
Note: There are many Stack Overflow issues like this for reference.
TypeError: Cannot read property 'createOscillator' of null
at Object.audio in morsify/src/morsify.js — line 192
Although there's a decent workaround to being able to seek, pause and stop the audio by binding the wave to an audio control (see #25 (comment)), the underlying API is a little confusing and/or lacking in function:
All of these items make it difficult to build a complete UI to interface with the library.
I see no reason why we couldn't just re-render the audio if necessary when someone hits play again. Their intent is obvious, and the audio becoming unplayable after stop is not obvious.
The use of the offline audio context makes it possible to keep the audio buffer in memory and re-use it!
This has the downside though of potentially keeping a large audio buffer around though, so this could be an optimisation option.
e.g. perhaps stop could take in a boolean parameter that indicates if the buffer should be disposed - stop(true)
and otherwise you could call audio.dispose() to remove the buffer.
Add seek (or setCurrentTime()) to allow playback from any point in the audio, pause would act the same as stop except that it would not reset the currentTime to 0, so a subsequent play would resume from that point.
Expose getCurrentTime() and getTotalTime() on the audio object. These would be functions because it might be expensive/unnecessary to poll and update a current time property; getTotalTime would need to wait until rendering had completed (although you could get the total duration time before even playing the audio)
One gotcha with having re-playable/pausable audio is the onended event as this will now be triggered every time the playback stops (even on pause); we could simply rename this event to onstopped and include the current time in the event object (so you could see if it was paused or completed), or make onended only trigger at the end of the audio or when disposed. It might also be useful to know when the audio has finished rendering - onready, and we could re-work the API to allow synchronous usage via this callback if that seems useful.
Currently, the library misses a feature that is a bit challenging: exporting the Morse code audio to WAV.
Not sure how to do this effectively, but the gist below clearly shows how to create WAV from the buffer, which may help in the beginning.
Hi @ozdemirburak
When i am clicking first time on the playicon then the audio has been start playing but as soon as i am clicking again to pause the audio it showing me this error "Failed to execute 'stop' on 'AudioScheduledSourceNode': cannot call stop without calling start first."
I am unable to understand what i am making wrong. Please help some one.
const morse = require('morse-decoder');
const togglePlay = (event) => {
const audio = morse.audio('My Text');
if (event.target.className === 'playicon') {
audio.play();
event.target.className = 'pauseicon';
} else {
audio.stop();
event.target.className = 'playicon';
}
}
<div className="playicon" onClick={togglePlay}></div>
Is it possible to send HTTP requests to https://morsedecoder.com/ with content and get the encoded value?
If it's not possible, is it possible to add it as a new feature to the site?
Currently, there are two variables that control the sound - unit and fwUnit. And these confuse most users about the Audio generated.
Instead of these two, taking PARIS (50 units) as the standard word (60 seconds / 50 units = 1.2), a WPM parameter for an end user would be better.
Here is a great resource on this: https://www.morsecodeclassnet.com/ch3-timing/
Other than this, the current default frequency value is 500, but a more common value would be better.
Lastly, a volume parameter can also be added.
Here is the expected output:
const options: Options = {
...opts,
dash: opts.dash || '-',
dot: opts.dot || '.',
space: opts.space || '/',
separator: opts.separator || ' ',
invalid: opts.invalid || '#',
priority: opts.priority || 1,
>>>>>>>wpm: opts.wpm || 20,
>>>>>>>volume: opts.volume || 100,
oscillator: {
...opts.oscillator,
type: opts.oscillator?.type || 'sine', // sine, square, sawtooth, triangle
>>>>>>>frequency: opts.oscillator?.frequency || SOME_ANOTHER_VALUE, // value in hertz
onended: opts.oscillator?.onended || null // event that fires when the tone has stopped playing
}
};
You can see the letter Ґ here http://old.plast.org.ua/files/files/users/10701/Morse_alphabet.pdf or on Ukrainian wiki page about Morse code.
Morse Code for ґ\Ґ — "--."
Currently, there is only one typescript file, index.ts.
To split the logic, you can create files like:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.