#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': '--..',
'':'-----',
'':'.----',
'':'..---',
'':'...--',
'':'....-',
'':'.....',
'':'-....',
'':'--...',
'':'---..',
'':'----.',
' ':' ',
} wave_dict = {
'a':r'F:\personal\Radio\cw_sound\A.wav',
'b':r'F:\personal\Radio\cw_sound\B.wav',
'c':r'F:\personal\Radio\cw_sound\C.wav',
'd':r'F:\personal\Radio\cw_sound\D.wav',
'e':r'F:\personal\Radio\cw_sound\E.wav',
'f':r'F:\personal\Radio\cw_sound\F.wav',
'g':r'F:\personal\Radio\cw_sound\G.wav',
'h':r'F:\personal\Radio\cw_sound\H.wav',
'i':r'F:\personal\Radio\cw_sound\I.wav',
'j':r'F:\personal\Radio\cw_sound\J.wav',
'k':r'F:\personal\Radio\cw_sound\K.wav',
'l':r'F:\personal\Radio\cw_sound\L.wav',
'm':r'F:\personal\Radio\cw_sound\M.wav',
'n':r'F:\personal\Radio\cw_sound\N.wav',
'o':r'F:\personal\Radio\cw_sound\O.wav',
'p':r'F:\personal\Radio\cw_sound\P.wav',
'q':r'F:\personal\Radio\cw_sound\Q.wav',
'r':r'F:\personal\Radio\cw_sound\R.wav',
's':r'F:\personal\Radio\cw_sound\S.wav',
't':r'F:\personal\Radio\cw_sound\T.wav',
'u':r'F:\personal\Radio\cw_sound\U.wav',
'v':r'F:\personal\Radio\cw_sound\V.wav',
'w':r'F:\personal\Radio\cw_sound\W.wav',
'x':r'F:\personal\Radio\cw_sound\X.wav',
'y':r'F:\personal\Radio\cw_sound\Y.wav',
'z':r'F:\personal\Radio\cw_sound\Z.wav',
'':r'F:\personal\Radio\cw_sound\1.wav',
'':r'F:\personal\Radio\cw_sound\2.wav',
'':r'F:\personal\Radio\cw_sound\3.wav',
'':r'F:\personal\Radio\cw_sound\4.wav',
'':r'F:\personal\Radio\cw_sound\5.wav',
'':r'F:\personal\Radio\cw_sound\6.wav',
'':r'F:\personal\Radio\cw_sound\7.wav',
'':r'F:\personal\Radio\cw_sound\8.wav',
'':r'F:\personal\Radio\cw_sound\9.wav',
'':r'F:\personal\Radio\cw_sound\0.wav',
' ':' ',
} print("\n")
print("Please input a string(999 to exit):")
print("\n\n")
code = 'initial' while(code!=''):
code = raw_input()
if(code == ''):
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('\n')
音频文件使用业余无线电常用的软件 CW Player逐个生成。