A typical defibrillator is basically capacitor and a pair of electrodes and circuits. There are AEDs that can detect whether defibrillation is required or not. But what if cardiac arrest(due to ventricular fibrillation, pulseless ventricular tachycardia or other conditions for which defibrillation is indicated) occurs and standard defibrillator is not available, can other sources of electrical power, if available, be used for defibrillation?? Or just CPR has to be performed until emergency services arrive? I live in a country where awareness about CPR is low. And defibrillators are not that common. *I am studying MBBS.
Although you might cobble something together that can deliver the appropriate levels of shock, the problem is what @Graham Chiu has been hinting at in his comments. Not all forms of cardiac arrest are shockable.
Rhythms that are not amenable to shock include pulseless electrical activity (PEA) and asystole. In these cases, identifying primary causation, performing good CPR, and administering epinephrine are the only tools you have to resuscitate the patient.
This is a big part of what an automatic external defibrillator (AED) does for you. In addition to the relatively simple electronics that deliver the shocks, an AED also contains an EKG and a microprocessor that interprets the rhythm and decides whether a shock is appropriate or not, and that is definitely not something simple you can cobble together. Now, you could take the approach of saying a homemade defibrillator is better than nothing, but that's not true. Shocking asystole or PEA is a waste of time, it deprives the patient of CPR for several seconds, and above all it can cause harm.
Applying current to a heart in asystole can result in myocardial damage and is contraindicated.
Since there's no way to distinguish between shockable and non-shockable rhythms without an EKG or AED, your only recourse is CPR.