#python 2.7 #!/usr/bin/env python # -*- coding:utf-8 -*- import os import winsound,sys,time __author__ = 'BH8ANK' morse_dict = { 'a':'.-', 'b':'-...', 'c':'-.-.', 'd':'-..', 'e':'.', 'f':'..-.', 'g':'--.', 'h':'....', 'i':'..', 'j':'.---', 'k':'-.-', 'l':'.-..', 'm':'--', 'n':'-.', 'o':'---', 'p':'.--.', 'q':'--.-', 'r':'.-.', 's':'...', 't':'-', 'u':'..-', 'v':'...-', 'w':'.--', 'x':'-..-', 'y':'-.--', 'z':'--..', 'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--', 'Z': '--..', '0':'-----', '1':'.----', '2':'..---', '3':'...--', '4':'....-', '5':'.....', '6':'-....', '7':'--...', '8':'---..', '9':'----.', ' ':' ', } wave_dict = { 'a':r'F:personalRadiocw_soundA.wav', 'b':r'F:personalRadiocw_soundB.wav', 'c':r'F:personalRadiocw_soundC.wav', 'd':r'F:personalRadiocw_soundD.wav', 'e':r'F:personalRadiocw_soundE.wav', 'f':r'F:personalRadiocw_soundF.wav', 'g':r'F:personalRadiocw_soundG.wav', 'h':r'F:personalRadiocw_soundH.wav', 'i':r'F:personalRadiocw_soundI.wav', 'j':r'F:personalRadiocw_soundJ.wav', 'k':r'F:personalRadiocw_soundK.wav', 'l':r'F:personalRadiocw_soundL.wav', 'm':r'F:personalRadiocw_soundM.wav', 'n':r'F:personalRadiocw_soundN.wav', 'o':r'F:personalRadiocw_soundO.wav', 'p':r'F:personalRadiocw_soundP.wav', 'q':r'F:personalRadiocw_soundQ.wav', 'r':r'F:personalRadiocw_soundR.wav', 's':r'F:personalRadiocw_soundS.wav', 't':r'F:personalRadiocw_soundT.wav', 'u':r'F:personalRadiocw_soundU.wav', 'v':r'F:personalRadiocw_soundV.wav', 'w':r'F:personalRadiocw_soundW.wav', 'x':r'F:personalRadiocw_soundX.wav', 'y':r'F:personalRadiocw_soundY.wav', 'z':r'F:personalRadiocw_sound.wav', '1':r'F:personalRadiocw_sound1.wav', '2':r'F:personalRadiocw_sound2.wav', '3':r'F:personalRadiocw_sound3.wav', '4':r'F:personalRadiocw_sound4.wav', '5':r'F:personalRadiocw_sound5.wav', '6':r'F:personalRadiocw_sound6.wav', '7':r'F:personalRadiocw_sound7.wav', '8':r'F:personalRadiocw_sound8.wav', '9':r'F:personalRadiocw_sound9.wav', '0':r'F:personalRadiocw_sound .wav', ' ':' ', } print(" ") print("Please input a string(999 to exit):") print(" ") code = 'initial' while(code!='999'): code = raw_input() if(code == '999'): print('Bye!') break for i in code: print str(morse_dict[i]), if(' ' == i): time.sleep(0.25) if(' ' != i): winsound.PlaySound(wave_dict[i], winsound.SND_NODEFAULT) # os.system("paplay BEEP1.WAV") print(' ')
音频文件使用业余无线电常用的软件 CW Player逐个生成。