Can I use a earphone (with mic) to use voice recognition feature of any AI API (like Alexa)in raspberry pi
Unfortunately the existing 3.5mm jack on the Pi is for audio out and not audio in. However there is a solution...
You can use a USB sound card that has the mic functionality. You can get USB sound cards that have either the 4-ring single 3.5mm jack or one with separate line-in and line-out jacks. Alternatively, you could just buy USB microphone for the audio in and use the existing jack for audio out.
For the sound card (or microphone) you choose, you should make sure that it works with the standard Linux sound drivers or else drivers have been written for that particular sound card.
These sites discuss what voice recognition software to use and how to implement them:
Unfortunately, according to the documentation, you cannot:
2. WHAT ABOUT STANDARD AUDIO IN AND OUT?
There is a standard 3.5mm jack for audio out to an amplifier. You can add any supported USB microphone for audio in or, using the I2S interface, you can add a codec for additional audio I/O.