[{"data":1,"prerenderedAt":296},["ShallowReactive",2],{"news-item-\u002Fvi\u002Fnews\u002Fgcp-webservice-laravel-2":3},{"id":4,"title":5,"body":6,"category":284,"created by":285,"date":286,"description":287,"extension":288,"meta":289,"navigation":135,"path":290,"sections":291,"seo":292,"stem":293,"thumbnail":294,"__hash__":295},"content_vi\u002Fvi\u002Fnews\u002Fgcp-webservice-laravel-2.md","ỨNG DỤNG LARAVEL TRONG GOOGLE CLOUD PLATFORM (GCP) - PHẦN 2",{"type":7,"value":8,"toc":272},"minimark",[9,14,26,29,35,38,41,66,69,77,87,92,102,105,109,124,129,132,142,145,149,152,156,162,164,169,172,175,183,186,190,194,200,204,209,212,215,219,228,232,234,239,242,247,254,260,266],[10,11,13],"h2",{"id":12},"vi-triển-khai-speech-to-text-api","VI. Triển khai Speech To Text API",[15,16,17,18,25],"p",{},"Bạn có thể tham khảo trang tài liệu API tại ",[19,20,24],"a",{"href":21,"rel":22},"https:\u002F\u002Fcloud.google.com\u002Fspeech-to-text\u002Fdocs\u002Fquickstart-client-libraries",[23],"nofollow","đây",".",[15,27,28],{},"Cài đặt thư viện client:",[15,30,31],{},[32,33,34],"code",{},"composer require google\u002Fcloud-speech",[15,36,37],{},"Bây giờ bạn có thể sử dụng Speech-to-Text để chuyển một tập tin âm thanh thành văn bản.",[15,39,40],{},"Chúng tôi sẽ tạo một controller để xử lý 3 điều:",[42,43,45,48,63],"div",{"style":44},"margin-left: 20px;",[15,46,47],{},"1. Nhận file âm thanh được tải lên từ request",[15,49,50,51,55,56],{},"2. Chuyển đổi tập tin âm thanh sang ",[52,53,54],"strong",{},"FLAC"," với thư viện ",[19,57,60],{"href":58,"rel":59},"https:\u002F\u002Fwww.ffmpeg.org\u002F",[23],[52,61,62],{},"FFMpeg",[15,64,65],{},"3. Sử dụng đoạn code dưới để hiển thị văn bản nhận được từ API Speech-to-Text",[15,67,68],{},"Trong SpeechToTextController:",[70,71,73,74,76],"h3",{"id":72},"_1-chuyển-đổi-tập-tin-âm-thanh-nhận-được-sangflactừ-yêu-cầu","1. Chuyển đổi tập tin âm thanh nhận được sang ",[52,75,54],{}," từ yêu cầu",[78,79],"img",{"className":80,"alt":84,"src":85,"style":86},[81,82,83],"block","mx-auto","mb-4","","https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F25170415\u002FScreen-Shot-0032-04-21-at-11.04.26.png","width: 60%;",[15,88,89],{},[52,90,91],{},"Tại sao chuyển đổi sang FLAC là cần thiết?",[93,94,95,99],"ul",{},[96,97,98],"li",{},"Khi sửa dụng API Speech-to-Text thì cấu hình là yêu cầu bắt buộc (lớp RecognitionConfig).",[96,100,101],{},"AudioEncoding là trường quan trọng, khuyên bạn nên xài format FLAC hay LINEAR16 để có 1 kết quả tốt nhất.",[15,103,104],{},"Hiển thị văn bản nhận được",[78,106],{"className":107,"alt":84,"src":108,"style":86},[81,82,83],"https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F25170439\u002FScreen-Shot-0032-04-21-at-11.05.38.png",[15,110,111,112,115,116,119,120,123],{},"Tôi tạo một bản mẫu chỉ có 1 input-file có tên “",[52,113,114],{},"Choose File","“, một nút gửi có tên “",[52,117,118],{},"Transcribe","” và select-box để chọn ngôn ngữ với mặc định “",[52,121,122],{},"English(US)","”",[78,125],{"className":126,"alt":84,"src":127,"style":128},[81,82,83],"https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F25172423\u002FScreen-Shot-0032-04-21-at-11.13.52.png","width: 100%;",[15,130,131],{},"Chúng tôi sẽ chọn một tập tin âm thanh tiếng Nhật.",[133,134,137,138],"audio",{"controls":135,"style":136},true,"width: 100%","\n  ",[139,140],"source",{"src":141},"https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F25170906\u002Fjapanese_file.mp3",[15,143,144],{},"Và đây là kết quả:",[78,146],{"className":147,"alt":84,"src":148,"style":128},[81,82,83],"https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F25170545\u002FScreen-Shot-0032-04-21-at-11.56.52.png",[15,150,151],{},"Tuyệt! Nó hoạt động!",[10,153,155],{"id":154},"vii-triển-khai-text-to-speech-api","VII. Triển khai Text To Speech API",[15,157,17,158,25],{},[19,159,24],{"href":160,"rel":161},"https:\u002F\u002Fcloud.google.com\u002Ftext-to-speech\u002Fdocs\u002Fquickstart-client-libraries#client-libraries-usage-php",[23],[15,163,28],{},[15,165,166],{},[32,167,168],{},"composer require google\u002Fcloud-text-to-speech",[15,170,171],{},"Bây giờ bạn có thể sử dụng Text-to-Speech để tạo một file âm thanh của con người.",[15,173,174],{},"Chúng tôi sẽ tạo một controller để xử lý 2 điều:",[42,176,177,180],{"style":44},[15,178,179],{},"1. Nhận file văn bản được tải lên từ yêu cầu",[15,181,182],{},"2. Sử dụng mã dưới đây để tải xuống file âm thanh nhận được từ API chuyển văn bản thành giọng nói",[15,184,185],{},"Trong  TextToSpeechController:",[70,187,189],{"id":188},"_1-chuẩn-bị-mọi-thứ-trước-khi-chuyển-đổi","1. Chuẩn bị mọi thứ trước khi chuyển đổi",[78,191],{"className":192,"alt":84,"src":193,"style":86},[81,82,83],"https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F25170614\u002FScreen-Shot-0032-04-24-at-13.16.13.png",[15,195,196,197],{},"Trong hình trên, tôi có thể đặt một số cấu hình cho file âm thanh trước khi chuyển đổi, chẳng hạn như ",[52,198,199],{},"ngôn ngữ, giọng nói, giới tính, tốc độ …",[70,201,203],{"id":202},"_2-tải-xuốngfileâm-thanh-sau-khi-chuyển-đổi","2. Tải xuống file âm thanh sau khi chuyển đổi",[78,205],{"className":206,"alt":84,"src":207,"style":208},[81,82,83],"https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F25170643\u002FScreen-Shot-0032-04-24-at-13.26.44.png","width: 80%;",[15,210,211],{},"Các tập tin âm thanh sẽ được nhận dưới dạng MP3.",[15,213,214],{},"Sau đó, tôi đã tạo bản mẫu cho chức năng Text-to-speech. Nhưng lần này, bản mẫu sẽ chi tiết hơn.",[78,216],{"className":217,"alt":84,"src":218,"style":128},[81,82,83],"https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F25173644\u002FScreen-Shot-0032-04-24-at-13.47.28-1.png",[15,220,221,222,227],{},"Chúng tôi sẽ chọn một tập tin ",[19,223,226],{"href":224,"rel":225},"https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F28125501\u002Fjapanese.txt",[23],"văn bản"," tiếng Nhật. Và chọn các lựa chọn trên màn hình.",[78,229],{"className":230,"alt":84,"src":231,"style":128},[81,82,83],"https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F25170749\u002FScreen-Shot-0032-04-24-at-14.06.20.png",[15,233,144],{},[133,235,137,236],{"controls":135,"style":136},[139,237],{"src":238},"https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F25170937\u002Ftext-to-speech-file.mp3",[15,240,241],{},"Tuyệt vời!!!",[15,243,244],{},[52,245,246],{},"Link tham khảo:",[15,248,249,250],{},"1. ",[19,251,252],{"href":252,"rel":253},"https:\u002F\u002Fcloud.google.com\u002Fvision\u002Fdocs\u002Focr#vision_text_detection-php",[23],[15,255,256,257],{},"2. ",[19,258,21],{"href":21,"rel":259},[23],[15,261,262,263],{},"3. ",[19,264,160],{"href":160,"rel":265},[23],[15,267,268,269],{},"4. ",[19,270,58],{"href":58,"rel":271},[23],{"title":84,"searchDepth":273,"depth":273,"links":274},2,[275,280],{"id":12,"depth":273,"text":13,"children":276},[277],{"id":72,"depth":278,"text":279},3,"1. Chuyển đổi tập tin âm thanh nhận được sang FLAC từ yêu cầu",{"id":154,"depth":273,"text":155,"children":281},[282,283],{"id":188,"depth":278,"text":189},{"id":202,"depth":278,"text":203},"tech talk","Briswell Vietnam Co Ltd","2020-06-05","VI. Triển khai Speech To Text API. Bạn có thể tham khảo trang tài liệu API tại đây. Cài đặt thư viện client","md",{},"\u002Fvi\u002Fnews\u002Fgcp-webservice-laravel-2",null,{"title":5,"description":287},"vi\u002Fnews\u002Fgcp-webservice-laravel-2","https:\u002F\u002Fhomepage-media.s3.ap-southeast-1.amazonaws.com\u002Fwp-content\u002Fuploads\u002F2020\u002F05\u002F26155516\u002F0_brH9cM9rnSRx2I-S-1.png","pe1ZT7f-SWQFD5AFNCaln9SPYx8xLAV9crYIoLKowU0",1785320524994]