Can I connect 14 gauge wire to 12 gauge wire
Depends on the Breaker
The breaker protects the devices but also protects the wiring. Too much current heats up the wires in the walls --&gt; fire! You have two likely possibilities:

15A Breaker

14 AWG wire is rated for 15A of current. If the circuit is already on a 15A breaker then you can go ahead and swap any or all of the 12 AWG wiring for 14 AWG without any problems.

20A Breaker

12 AWG wire is rated for 20A of current. If the circuit is currently on a 20A breaker then you can't have 14 AWG wire in the circuit. You can either continue to use 12 AWG wire everywhere or you can replace the 20A breaker with a 15A breaker. However, if you replace the breaker then you may want to mark it in the panel because the next person might see 12 AWG wire connected and think that it could be replaced with a 20A breaker.
Keep in mind that a 20A breaker (and matching wire) can be very useful even if you don't have any individual devices that need 20A. For example, if you have a 15A circuit and someone plugs in a heating device (hair dryer, portable heater, toaster oven, etc.) it will typically draw ~ 12A = 1,440 watts while in use. That leaves only ~ 3A to spare for all lights, fans, TVs, computers, etc. that share the circuit. With a 20A circuit, you have 7A to spare, which can make the difference between having nuisance trips (or avoidance of usage) or not.