Skip to main content

Tạo ứng dụng AI đầu tiên - a piece of cake

Thư viện ngày gió to, nhìn quanh được 4 chú sinh viên già, quen mặt. Canada dạo này nát thật. Từ 2024, chính phủ hạn chế dân tạm cư, du học sinh quốc tế thưa thớt hẳn.

Tui mất 1h30 để cài đặt và configure viết ra ứng dụng đầu tiên để chọc đến các API của AI platform.

Bài toàn tương đối đơn giản:

"Tui hỏi bằng miệng, AI trả lời"

Ơ hay, thế bình thường khi dùng AI thì không thế à? Haha, bình thường bạn dùng sẵn app của nó, còn đây tui đang tự build cái app đó để customize theo cái ý đồ riêng của tôi để chơi với con robot.

Phân tích flow chương trình về mặt kỹ thuật:

Bạn nói => Module chuyển từ giọng nói sang text => cho cái text này vào AI bằng cách gọi API của AI => nhận response và hiển thị lên màn hình console

Okay, nghe có vẻ đơn giản, giờ ta bắt tay vào làm theo thought process

1. Chọn ngôn ngữ nào?

Mình muốn ăn liền nên python là chuẩn bài = > Python 3.8+

2. Dùng module nào để convert?

Cái nào lightweight rẻ tiền thì dùng, miễn phí càng tốt =>

Để truy cập được vào microphone:

PyAudio – for accessing the microphone.

Để convert giọng nói sang text

Speech Recognition – for converting voice to text.

Thằng này ngon, dùng phát ăn ngay

Whisper

Thằng này thì rẻ và kết hợp được luôn với AI model như OpenRouter

Cơ mà có cái dở là bước làm nó hơi khác. Nó sẽ thu âm thanh vào file wav lưu tại local, sau đó dùng một model AI để transcribe audio sang text.

3. AI thì chọn thằng nào?

Sau một hồi do research thì go with OpenRouter. Nó rẻ, và mình fix được mấy lỗi linh tinh ngu ngốc do AI generate code ra.

Tada.... đây là sản phẩm đầu ra.


Trông dễ vậy thôi cơ mà cũng phải bẩy bẩy bốn chín cái cấu hình và setup nữa nhé các bạn trẻ.

Game là dễ.

Giờ đi làm trận fifa07 tự thưởng cho ouput ngày hôm nay

What's next?

Sau đó đến lượt tống thêm Text to speech để nó nói, rồi tống dữ liệu này ra đường serial bắn sang con arduino điều khiển cái đầu robot. 

Xin lỗi các bạn, tôi là dân làm embedded software mà, chơi với PC không thỏa mãn cái thú táy máy của tôi. Tiếp theo là tôi sẽ tìm cách nhúng cái app này vào mấy cái hardware platform như raspberry pi/ jetson nano .. ahihi






Comments

Popular posts from this blog

[STM32] How to configure Timer 1, Channel 3 is PWM 1kHz, duty cycle 20% to control BLDC motor

 To configure Timer1 for a 1 kHz PWM signal with a 20% duty cycle on an STM32H7S3L8 microcontroller, follow these steps: 1. Understand the Timer Parameters PWM Frequency : 1 kHz → Period = 1 ms. Duty Cycle : 20% → ON time = 0.2 ms. The timer’s clock frequency is derived from the APB clock (e.g., TIMCLK). Let’s assume you know the APB clock frequency. The Timer prescaler and auto-reload register (ARR) define the PWM frequency. 2. Compute Timer Parameters Formula: PWM Frequency = Timer Clock (Prescaler + 1) * (ARR + 1) \text{PWM Frequency} = \frac{\text{Timer Clock}}{\text{(Prescaler + 1) * (ARR + 1)}} PWM Frequency = (Prescaler + 1) * (ARR + 1) Timer Clock ​ For 1 kHz PWM: A R R = Timer Clock PWM Frequency ∗ ( Prescaler + 1) − 1 ARR = \frac{\text{Timer Clock}}{\text{PWM Frequency} * (\text{Prescaler + 1)}} - 1 A RR = PWM Frequency ∗ ( Prescaler + 1) Timer Clock ​ −...

How to use ChatGPT to get your resume shortlisted?

How to use ChatGPT to get your resume shortlisted? Core steps: Chat GPT -> Resume Creator -> LinkedIn(Copy the job description to ChatGPT) -> Add your personal information -> Copy output from ChatGPT to Instaresume.io to make the template -> Goto SkillSyncer to check ATS(Applicant Tracking Software) score, point out the missing keywords. Detail ☑️In my pursuit of job #opportunities, I encountered a familiar challenge - my resume seemingly disappeared into oblivion, yielding no responses despite my diverse skill set and numerous applications. ☑️As I delved into my research, I uncovered the existence of ATS software, the automated gatekeeper of #resumes, which swiftly filtered out those lacking relevant keywords. ☑️The outcome? Not just one #company, but over a dozen organizations recognized the potential in my resume, resulting in multiple shortlists and promising #job prospects! 💻If you want to supercharge your resume and unlock countless opportunities, don't miss o...

[Mentorship] First day at work - question for your co-workers (casual and friendly tone)

Summary Learn essential tips to make a positive first impression on your first day at a new job, ensuring success and connection with colleagues. Highlights⏰ Be punctual: Arrive early to show commitment. ( 15 minutes before your shift ) 🚫 Avoid gossip: Maintain professionalism and integrity. ❌ Don’t ask for time off: Show dedication to your new role. 🤝 Firm handshake: A confident greeting sets a great tone. 📚 Ask questions: Engage with your new role actively. 🗂️ Organize your workspace: Keep your area tidy for respect. ☕ Accept social invites: Build rapport with co-workers. Key Insights ⏳ First Impressions Matter: Your colleagues will form opinions quickly, so be on your best behavior right from the start. 🌟 Professional Appearance: Dressing smartly conveys seriousness about your role and can positively influence how others perceive you. 💬 Communication is Key: A warm greeting and engaging dialogue can help break the ice and make you more approachable. 📝 Active Learning: Asking ...