- Notifications
You must be signed in to change notification settings - Fork0
Not only translates Morse code into text and vice versa but also features audio playback for seamless decoding. Dive into the world of communication history or sharpen your skills with practical applications. Decode, translate, and immerse yourself in the rhythmic language of Morse code.
License
reblox01/morse-decoder
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Morse Code Translator with Audio - Morse Decoder
Morse code encoder and decoder with no dependencies. It supports Latin, Cyrillic, Greek, Hebrew, Arabic,Persian, Japanese, Korean, and Thai, with audio-generation functionality using theWeb Audio API.
$ npm install morse-decoder --save
$ yarn add morse-decoder
constmorse=require('morse-decoder');constencoded=morse.encode('SOS');// ... --- ...constdecoded=morse.decode('... --- ...');// SOSconstcharacters=morse.characters();// {'1': {'A': '.-', ...}, ..., '11': {'ㄱ': '.-..', ...}}constaudio=morse.audio('SOS');audio.play();// play audioaudio.stop();// stop audioaudio.exportWave();// download audio wave file (promise)consturl=awaitaudio.getWaveUrl();// get audio wave url (promise)constblob=awaitaudio.getWaveBlob();// get audio wave blob (promise)
You can customize the dash, dot, or space characters and specify the alphabet with the priority option foran accurate encoding and decoding.
The priority option gives direction to the plugin to start searching for the given character set first.
Set the priority option according to the list below.
- 1 => ASCII (Default)
- 2 => Numbers
- 3 => Punctuation
- 4 => Latin Extended (Turkish, Polish etc.)
- 5 => Cyrillic
- 6 => Greek
- 7 => Hebrew
- 8 => Arabic
- 9 => Persian
- 10 => Japanese
- 11 => Korean
- 12 => Thai
constcyrillic=morse.encode('Ленинград',{priority:5});// .-.. . -. .. -. --. .-. .- -..constgreek=morse.decode('... .- --. .- .--. .--',{priority:6});// ΣΑΓΑΠΩconsthebrew=morse.decode('.. ––– . –––',{dash:'–',dot:'.',priority:7});// יהוהconstjapanese=morse.encode('NEWS',{priority:10,dash:'-',dot:'・',separator:' '});// -・ ・ ・-- ・・・constcharacters=morse.characters({dash:'–',dot:'•'});// {'1': {'A': '•–', ...}, ..., '11': {'ㄱ': '•–••', ...}}constarabicAudio=morse.audio('البراق',{// generates the Morse .- .-.. -... .-. .- --.- then generates the audio from itunit:0.1,// period of one unit, in seconds, 1.2 / c where c is speed of transmission, in words per minutefwUnit:0.1,// period of one Farnsworth unit to control intercharacter and interword gapsoscillator:{type:'sine',// sine, square, sawtooth, trianglefrequency:500,// value in hertzonended:function(){// event that fires when the tone stops playingconsole.log('ended');}}});constoscillator=arabicAudio.oscillator;// OscillatorNodeconstcontext=arabicAudio.context;// AudioContext;constgainNode=arabicAudio.gainNode;// GainNodearabicAudio.play();// will start playing Morse audioarabicAudio.stop();// will stop playing Morse audio
Contributions are welcome.
Install node and npm and run the commands below.
$ npm install# generate `index.js` inside `src`$ npm run build# generate `morse-decoder.min.js` (minified) inside `dist`$ npm run build-rel
The MIT License (MIT). Please seeLicense File for more information.
About
Not only translates Morse code into text and vice versa but also features audio playback for seamless decoding. Dive into the world of communication history or sharpen your skills with practical applications. Decode, translate, and immerse yourself in the rhythmic language of Morse code.