2023年11月23日 星期四

有道理, 但AI改變了什麼?

 

資料來源:李海碩台大語言中心演講

2023年11月20日 星期一

查表

 # a = ['apple','orange']

# b = ['蘋果','柳橙']

# indata = input('請輸入英文水果名:')


# if indata == 'apple':

#     print('蘋果')

# if indata == 'orange':

#     print('柳橙')


# a = '0123456789ABCDEF'

# b = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]


# indata = input('請輸入16進位數字:')

# i = 0

# while a[i] != indata:

#     i+=1

# print(b[i])


# a = '0123456789ABCDEF'

# b = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]

# indata = 'E'

# f =  a.find(indata)

# print(b[f])


# f1 = a.find('F')

# print(b[f1])


# a = ['I','IV','V','IX','X']

# b = [1,4,5,9,10]


# indata = 'VII'


# n = 0

# for i in indata:

#     f = a.index(i)

#     n=n + b[f]

# print(n)


# a = ['I','IV','V','IX','X','XL','L']

# b = [1,4,5,9,10,40,50]


# indata = 'IXVIIIXXL'


# n = 0

# i = 0

# while  i <len(indata):

#     if indata[i:i+2] in a:

#         f2 = a.index(indata[i:i+2])

#         n = n +b[f2]

#         i = i +2

#     else:

#         f = a.index(indata[i])

#         n=n + b[f]

#         i = i +1

# print(n)


# a = ['I','IV','V','IX','X','XL','L']

# b = [1,4,5,9,10,40,50]


d = {'I':1,'IV':4,'V':5,'IX':9,'X':10,'XL':40,'l':50}

indata = 'IXVIIIXXL'


n = 0

i = 0

while  i <len(indata):

    if indata[i:i+2] in d:

        n = n +d[indata[i:i+2]]

        i = i +2

    else:

        n = n +d[indata[i]]

        i = i +1

print(n)

2023年11月6日 星期一

text to Speech Sample

# 先在console 視窗下  pip install gTTs

 from gtts import gTTS

import os

import subprocess


# 要轉換的文本

text = "明天會更好tomorrow will be better"


# 創建TTS物件

tts = gTTS(text, lang='zh-tw')  # 使用台灣華語語音


# 將語音儲存為檔案

tts.save("output.mp3")


# 播放語音

# os.system("mpg321 output.mp3")  # 需要安裝mpg321或使用其他播放器

# os.system("start wmplayer.exe output.mp3") #windows 10

subprocess.call(["start", "output.mp3"], shell=True) # windows 11


# 刪除暫存檔案

# os.remove("output.mp3")

text to speech , speech to text 參考網頁

 Speechnotes | Speech to Text Online Notepad

Free Text to Speech Online with Realistic AI Voices